Skip to content

Commit

Permalink
1.整理fullExaple的文件
Browse files Browse the repository at this point in the history
2.把核心和其他类移动至module文件夹,分模块的思想
3.修改了Dialog绑定功能的代码,使用事件队列和遍历来实现同一个index要执行不同代码的功能 如在第二句话时,同时切换bgm和人物
4.预计要添加存档API但是,由于存档功能在另外一个界面,所以使用cookie来临时存储进度,但是有bug,todo
5.localStorage存档作用于每个独立的html文件,不可以通用/目录,但cookie可以,所以,后续可能做一个存档和读档中心.html,把存档读档功能做在一个界面里面就行了。
  • Loading branch information
2439905184 committed Jan 29, 2021
1 parent ec8852a commit 2375c31
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 89 deletions.
51 changes: 0 additions & 51 deletions Logic.js

This file was deleted.

12 changes: 3 additions & 9 deletions fullExample/Load.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<script src="../core.js"></script>
<script src="../FileSystem.js"></script>
<script src="../bgm.js"></script>
<script src="../changeScene.js"></script>
<script src="../module/changeScene.js"></script>
<link rel="stylesheet" href="css/button.css">
</head>
<body>
<img src="img/mini_menu_save.jpg">
Expand All @@ -23,15 +24,8 @@
{
$("#back").click(function()
{
changeScene("Title.html")
changeScene("index.html")
})
for(var i=0;i<2;i++)
{
$("button").css("background","orange")
$("button").css("border","solid")
$("button").css("width","100px")
$("button").css("height","50px")
}
})
</script>
</body>
Expand Down
13 changes: 1 addition & 12 deletions fullExample/Logic.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
$(function()
{
var Engine=new EasyAvg()
//Engine.showBgm()
/*Engine.hideBgm()*/
//Engine.changeBgm("bgm/i71004_fresh.ogg")

function initBg()
{
var bg=$("#bg")
Expand All @@ -24,7 +20,7 @@ $(function()
$("#newGame").click(function()
{
alert("新游戏")
changeScene("../index.html")
changeScene("Scene/Game.html")
})
$("#loadGame").click(function()
{
Expand All @@ -39,13 +35,6 @@ $(function()
{
alert("感谢您走进Noesis的世界 \n 这款游戏是由我们的同好会--classic_chocolat所制作")
})
/*for(var i=0;i<5;i++)
{
$("button").css("background","orange")
$("button").css("border","solid")
$("button").css("width","100px")
$("button").css("height","50px")
}*/

}
initBg()
Expand Down
9 changes: 8 additions & 1 deletion fullExample/SaveLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ $(function()
var UserSaveConfirmed=confirm("是否保存要进度")
if(UserSaveConfirmed)
{

var myFile=new FileSystem()
myFile.save("key","value")
var date=new Date()
$("li").text(date.toUTCString()+" "+"NEW!")
}
})
$("#back").click(function()
{
changeScene("Scene/Game.html")
})
})
12 changes: 6 additions & 6 deletions index.html → fullExample/Scene/Game.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
<!--<script src="jQuery_main.js"></script>-->
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="core.js"></script>
<script src="../../module/core.js"></script>
<script src="../../module/FileSystem.js"></script>
<script src="../../module/changeScene.js"></script>
<script src="Logic.js"></script>
<script src="FileSystem.js"></script>
<script src="bgm.js"></script>
<script src="changeScene.js"></script>
<!--内置button样式,如果不喜欢,可以自己建立css样式-->
<link rel="stylesheet" href="fullExample/css/button.css">
<link rel="stylesheet" href="../css/button.css">
<link rel="stylesheet" href="css/bgm.css">
</head>
<body>
<audio id="bgm" src="fullExample/bgm/i71004_fresh.ogg" volume="0.5" controls autoplay="true" loop="true"></audio>
<audio id="bgm" src="../bgm/i71004_fresh.ogg" controls autoplay="true" loop="true"></audio>
<h1> EasyAvgFramework </h1>
<button id="start">开始</button>
<button id="end">返回</button>
Expand Down
71 changes: 71 additions & 0 deletions fullExample/Scene/Logic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
$(function()
{
var file=new FileSystem()
alert("请先点击开始按钮来播放背景音乐,由于浏览器安全设置,不能自动播放,点击人物,也能开始播放音乐")
function initUI()
{
$("#end").click(function()
{
changeScene("../index.html")
})
$("#start").click(function()
{
$("#bgm")[0].play()
})
$("#loadGame").click(function()
{
changeScene("../Load.html")
})
}
initUI()

var Engine=new EasyAvg()
// NOTE: 需要先创建背景
var bg=Engine.create_img("../img/bg.jpg","背景")
var koyomi=Engine.create_img("../img/char.png","小夜美")
console.warn("#设置bgm音量");
$("#bgm")[0].volume=0.5
//改变人物动作 参数是第几个段落 index从0开始
//var koyomi_2=Engine.create_img("k18.png","k")
koyomi.css("margin-left","500px")
koyomi.css("margin-top","20px")
koyomi.click(function()
{
alert("点击了人物,开始播放音乐")
$("#bgm")[0].play()
})
var dialog=Engine.create_Dialog()
var text=['喂!?一爬起来就趴下可不成啊','今天第一节课是小考,所以昨天不是说好了要教我功课的吗','说好的了吧',"真是的,再不快点起来我会很困扰的啊"]
dialog.setContent(text)
dialog.setDebugLog(true)
//定义人物图片变化,定义bgm变化
dialog.changeImgAt(2,koyomi,"../img/k18.png")
dialog.changeBgmAt(2,"../bgm/i72008_momoiro_cherry.ogg")
var action=function MyFinishAction()
{
console.warn("#游戏结束#,来自逻辑层代码");
alert("结束")
changeScene("../index.html")
}
dialog.setFinishAction(action)
Engine.create_BackroundImg(bg)
$("body").append(bg)
$("body").append(koyomi)
$("body").append(dialog)
// NOTE: 绑定按钮code 存档
function bindingButtonAction(dialog)
{
$("#saveGame").click(function()
{
console.warn("##存档!");
//在跳转存档页面之前,先暂存游戏运行状态执行到哪一个句子的index
var index=dialog.getRuntimeIndex()
console.warn("#运行状态"+index);
$.cookie('runTimeIndex',index,{path:'/'})
//localStorage.setItem("test","test1ad3s1")
//file.save("runTimeIndex",index)
changeScene("../save.html")
})
}
bindingButtonAction(dialog)
})
Binary file added fullExample/bgm/i72008_momoiro_cherry.ogg
Binary file not shown.
2 changes: 1 addition & 1 deletion fullExample/css/save.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ ol
}
li
{
background-color: black;
background-color: grey;
margin-top: 5px;
}
File renamed without changes
File renamed without changes
File renamed without changes
7 changes: 3 additions & 4 deletions fullExample/Title.html → fullExample/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
<!--<script src="jQuery_main.js"></script>-->
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="../core.js"></script>
<script src="../module/core.js"></script>
<script src="../module/FileSystem.js"></script>
<script src="Logic.js"></script>
<script src="../FileSystem.js"></script>
<script src="../bgm.js"></script>
<script src="../changeScene.js"></script>
<script src="../module/changeScene.js"></script>
<link rel="stylesheet" href="css/button.css">
<link rel="stylesheet" href="css/bgm.css">
</head>
Expand Down
3 changes: 2 additions & 1 deletion fullExample/save.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://cdn.staticfile.org/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

<script src="../module/changeScene.js"></script>
<script src="../module/FileSystem.js"></script>
<script src="SaveLogic.js"></script>
</head>
Expand All @@ -20,6 +21,6 @@
<li></li>
<li></li>
</ol>
<button>返回</button>
<button id="back">返回</button>
</body>
</html>
File renamed without changes.
File renamed without changes.
26 changes: 22 additions & 4 deletions core.js → module/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function EasyAvg()
$("body").append(img)
img.css("z-index","-2")
img.css("position","absolute")

img.css("margin-left","200px")
}

// NOTE: 修改图片大小
Expand Down Expand Up @@ -70,14 +70,27 @@ this.create_Dialog=function(color)
var clicks=0
var dialog=$("<p></p>")
// NOTE: 对于每一个Dialog的内容的数组 初始化
//dialog.content=[]
// NOTE: 设置内容 string array
dialog.setContent=function(array)
{
content=array
console.log("#content")
console.log(content);
console.log(content)
// WARNING: 存在bug
// NOTE: 判断是否存在cookie 跳转保存页面后,自动恢复进度
var runTimeIndex=$.cookie("runTimeIndex",{path:'/'})
/* if(runTimeIndex)
{
console.warn("#存在cookie,使用临时值")
console.warn("当前cookie值")
console.log(runTimeIndex);
dialog.text(content[runTimeIndex])
}
else{
console.warn("#不存在零食进度,使用Logic.js定义的值");
dialog.text(content[0])
}*/
dialog.text(content[0])
// console.log("对话框"+dialog.content);
}
dialog.css("background","orange")
Expand All @@ -94,7 +107,7 @@ this.create_Dialog=function(color)
dialog.click(function()
{
clicks+=1
Global_clicks=clicks
// Global_clicks=clicks
dialog.text(content[clicks])
if(clicks>content.length&&finalAction==null)
{
Expand Down Expand Up @@ -182,6 +195,11 @@ this.create_Dialog=function(color)
{
to_do_Actions=[]
}
//获得运行时,index,跳转存档页面会丢失数据,用于暂存
dialog.getRuntimeIndex=function()
{
return clicks
}

//用户自定义Action 在指定的索引执行自定义代码
dialog.setCustomActionAt=function(index,func)
Expand Down
File renamed without changes.

0 comments on commit 2375c31

Please sign in to comment.