Skip to content

Commit

Permalink
1.初步完成存档读档功能,目前只能读取和保存单个游戏存档
Browse files Browse the repository at this point in the history
2.现在Demo必须在http服务器上(不管是本地服务器或者网络服务器都行),不然会报错 你可以python -m http.server 
启动服务器
3.添加了启动http服务器的cmd脚本>Windows用户
4.存档读档功能整合到了一个界面里面
5.一些细节调整
  • Loading branch information
2439905184 committed Jan 30, 2021
1 parent bdc2078 commit 0d1e7c6
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 17 deletions.
2 changes: 1 addition & 1 deletion fullExample/Logic.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $(function()
$("#loadGame").click(function()
{
alert("加载游戏")
changeScene("Load.html")
changeScene("save.html")
})
$("#dev").click(function()
{
Expand Down
82 changes: 75 additions & 7 deletions fullExample/SaveLogic.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,86 @@
// NOTE: 存档读档功能初步完成,现在只做了个单个存档存储和读取的功能,之后做多个存档的存储和读取
$(function()
{
$("li").click(function()
//初始化存档和读档index
var saveData_index=0
var loadData_index=0
//初始化文件系统
var fileManager=new FileSystem()
var gameDataManager=function(){}
var date=new Date()
var today=date.toDateString()+" "+"NEW!"
$("#loadList li").click(function()
{
var UserSaveConfirmed=confirm("是否保存要进度")
if(UserSaveConfirmed)
var saveState=confirm("读档吗?")
if(saveState)
{
var myFile=new FileSystem()
myFile.save("key","value")
var date=new Date()
$("li").text(date.toUTCString()+" "+"NEW!")
alert("!技术问题,搁置,请在下面手动输入来读档")
}
})
$("#saveList li").click(function()
{
//先询问是否存档
var saveState=confirm("存档吗?")
console.log($(this));
if(saveState)
{
var a=$("<li><img width='5%' src='img/k18.png' alt='存档截屏快照'>存档了"+" "+today+"NEW!"+"</li>")
//var i=$(this)[0].value
// console.log("i>"+i);
$(this).html(a)
//获得点击index
//读档界面同步更新
//$("#loadList li:eq("+i+")").html(a)
console.log("新存档!");
//存档index,从cookie临时缓存中取出来
var toSaveData=$.cookie("runTimeIndex")
console.log("cookieIndex#>"+toSaveData)
//更新saveIndex
fileManager.save("saveDataIndex",saveData_index)
fileManager.save("saveData",toSaveData)
saveData_index+=1
}
})
$("#back").click(function()
{
changeScene("Scene/Game.html")
})
//读档按钮
$("#loadGame").click(function()
{
var id=$("#loadId").val()
console.log("ID>"+id);
//取最大索引
var maxId=fileManager.load("saveDataIndex")
if(id>maxId)
{
alert("!错误,序号越界!")
}
//读存档到cookie
if(id<=maxId)
{
var index=fileManager.load("saveData")
//更新cookie
$.cookie("runTimeIndex",index,{path:'/'})
console.log("读取后数据为>"+index);
changeScene("Scene/Game.html")
//更新完毕cookie后,自动回到主界面,然后框架获取到cookie之后,自动恢复进度
//存档顺序cookie->localStorage
//读档顺序localStorage->cookie
/* 实际上是绕了一遍,但还是必须要绕一遍,因为cookie存储空间只有4kb,没有localStorage大,
且cookie是临时存储的,关闭浏览器就没有数据了,需要转持久化存储*/

}
})
})
/* $("li").click(function()
{
var UserSaveConfirmed=confirm("是否保存要进度")
if(UserSaveConfirmed)
{
var myFile=new FileSystem()
myFile.save("key","value")
var date=new Date()
$("li").text(date.toUTCString()+" "+"NEW!")
}
})*/
2 changes: 1 addition & 1 deletion fullExample/Scene/Game.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ <h1> EasyAvgFramework </h1>
<button id="loadGame">读档</button>
<button id="saveGame">存档</button>
<button id="clearCookie">清除自动暂存cookie</button>
<button id="reload">刷新页面</button>
<button id="clearClicks">清空计数器</button>
<button id="reload">刷新页面</button>
<h6> Copyright © 2020 小沙盒工作室&128hh. </h6>
</body>
</html>
39 changes: 32 additions & 7 deletions fullExample/save.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,40 @@
<link rel="stylesheet" href="css/bgm.css">
</head>
<body>
<audio src="bgm/free0701.ogg" controls="true" autoplay="true">你的浏览器不支持audio,快点换新的浏览器吧 </audio>
<!-- NOTE: 现在存档和读档功能合并在一个页面了 -->
<img src="img/mini_menu_save.jpg">
<ol>
<li></li>
<li></li>
<li></li>
</ol>
<audio src="bgm/i71004_fresh.ogg" controls="true" autoplay="true">你的浏览器不支持audio,快点换新的浏览器吧 </audio>
<h2>读档</h2>
<ol id="loadList">
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>

</ol>
<h2>存档</h2>
<img src="img/mini_menu_save.jpg">
<ol id="saveList">
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
<li><img width="5%">No Data</li>
</ol>
<h2>技术问题,读档需要手动输入要读取存档的序号</h2>
<input id="loadId" type="text" value="" placeholder="请输入要读取的存档的序号">
<button id="loadGame">读档</button>
<button id="reset">重置localStorage</button>
<button id="back">返回</button>
</body>
</html>
2 changes: 1 addition & 1 deletion module/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ function EasyAvg()
// 全局计数器,和dialog计数器同步更新
//var Global_clicks=0
//技术信息
$("body").append("<h6>Powered By <a traget='_blankhi' href='https://github.com/little-game-and-simple-software/EasyAvgFrameWork'>EasyAvgFramework</a></h6>")
$("body").append("<h6>Powered By <a traget='_blank' href='https://github.com/little-game-and-simple-software/EasyAvgFrameWork'>EasyAvgFramework</a></h6>")
//this.clicks=0
var sceen_objs=[123456]
//获得场景树
Expand Down

0 comments on commit 0d1e7c6

Please sign in to comment.