RGPJS 教程之八 创造场景
开始画面
游戏画面
代码
<!DOCTYPE html>
<html>
<head>
<script src="rpg-beta-2.js"></script>
<script>
var rpg;
RPGJS.loadPath = "rpgjs/core/";
RPGJS.load({
plugins: ['title']
}, function() {
rpg = new Rpg("canvas_rpg"); var scene = new Scene_Title(rpg);
scene.onExit = function(init) {
if (!init) return;
rpg.loadMap('MAP009', {
tileset: 'forest.png',
autotiles: ['002-G_Shadow01.png', '002-G_Shadow01.png', '003-G_Ground01.png', '004-G_Ground02.png', '011-G2_Ground02.png'],
events: ['EV001'],
player: {
x: 12,
y: 20,
direction: 'up',
filename: '001-Fighter01.png'
}
}, loadMap); } }); function loadMap() {
rpg.bind("eventCall_save", function() {
rpg.save(1);
window.location.reload();
});
rpg.setScreenIn("Player");
} </script>
</head>
<body style="margin: 0; overflow: hidden; background-color: #000;">
<canvas id="canvas_rpg" width="640px" height="480px"></canvas>
</body>
</html>
plugin/title.js
function Title() {
}
Title.prototype = {
Core: {
},
Event: {
}
}
function Window_Title(rpg, parent) {
this.parent = Window;
var h = 50;
if (rpg.slotExist(1)) {
h = 115;
}
this.parent(rpg, parent, 200, h);
}
var p = Window_Title.prototype = new Window();
p.onLoad = function() {
var self = this;
this.setPosition(this.rpg.canvas.width / 2 - this.width / 2, this.rpg.canvas.height - this.height - 40);
this.setBackOpacity(0.5);
var w = 6, h = 1;
this.addCommand(5, 12, w, h, function() { self.scene.newGame(); } );
this.drawText(30, 35, "New Game", "18px Arial", "#FFF");
if (this.rpg.slotExist(1)) {
this.addCommand(5, 47, w, h, function() { self.scene.loadGame(); });
this.addCommand(5, 82, w, h, function() { self.scene.deleteSlot(); });
this.drawText(30, 70, "Load Game", "18px Arial", "#FFF");
this.drawText(30, 105, "Delete Save", "18px Arial", "#FFF");
}
this.selectable();
}
p.update = function() {
}
function Scene_Title(rpg) {
this.parent = Scene;
this.parent(rpg);
this.main();
}
var p = Scene_Title.prototype = new Scene();
p.newGame = function() {
var self = this;
new Effect(this).fadeOut(5, function() {
self.exit(true);
})
}
p.loadGame = function() {
var self = this;
new Effect(this).fadeOut(5, function() {
self.exit();
self.rpg.load(1, loadMap);
})
}
p.deleteSlot = function() {
this.rpg.deleteSlot(1);
this.window_title.commands = [];
this.window_title.refresh();
this.window_title.setSize(200, 50);
this.window_title.onLoad();
this.window_title.index = 0;
this.window_title.moveCursor();
}
p.main = function() {
this.drawBackground('title.png');
this.window_title = this.addWindow(Window_Title);
}
RGPJS 教程之八 创造场景的更多相关文章
- iOS Sprite Kit教程之滚动场景
iOS Sprite Kit教程之滚动场景 滚动场景 在很多的游戏中,场景都不是静止的,而是滚动的,如在植物大战僵尸的游戏中,它的场景如图2.26所示. 图2.26 植物大战僵尸 在图2.26中,用 ...
- 超详细实战教程丨多场景解析如何迁移Rancher Server
本文转自Rancher Labs 作者介绍 王海龙,Rancher中国社区技术经理,负责Rancher中国技术社区的维护和运营.拥有6年的云计算领域经验,经历了OpenStack到Kubernetes ...
- Cocos2d-x 3.0final 终结者系列教程06-Director和场景跳转
这些天互联网大事不少呀 1.逻辑思维分家(所谓合久必分,分久必合,实属正常.切行切珍惜吧) 2. 锤子手机开卖 (无论你买没买,反正我没买,作为多年Android开发的我深知说的亮点事实上在我看来都 ...
- ASP.NET MVC4 新手入门教程之八 ---8.向模式中添加验证
在这本部分会将验证逻辑添加到Movie模式,和你会确保验证规则执行任何时候用户试图创建或编辑使用该应用程序的一部电影. 保持事物的干练性 ASP.NET MVC 的核心设计信条之一是 DRY(”Don ...
- (Python基础教程之八)Python中的list操作
Python基础教程 在SublimeEditor中配置Python环境 Python代码中添加注释 Python中的变量的使用 Python中的数据类型 Python中的关键字 Python字符串操 ...
- qtp:vbs基础教程
◎Vbs脚本编程简明教程之中的一个-为什么要使用Vbs? 在Windows中,学习计算机操作或许非常easy,可是非常多计算机工作是反复性劳动,比如你每周或许须要对一些计算机文件进行复制.粘贴.改名 ...
- Vbs 脚本编程简明教程之一
—为什么要使用 Vbs ? 在 Windows 中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改名.删除,也许你每天启动 计算机第一件 ...
- mybatis 教程(mybatis in action)
目录简介: 一:开发环境搭建二:以接口的方式编程 三:实现数据的增删改查 四:实现关联数据的查询 五:与spring3集成(附源码) 六:与Spring MVC 的集成 七:实现mybatis分页(源 ...
- VBS教程
Vbs是一种Windows脚本,它的全称是:Microsoft Visual Basic Script Editon.(微软公司可视化BASIC脚本版),VBS是Visual Basic的的一个抽象子 ...
随机推荐
- ASP.NET路由系统实现原理:HttpHandler的动态映射
我们知道一个请求最终通过一个具体的HttpHandler进行处理,而我们熟悉的用于表示一个Web页面的Page对象就是一个HttpHandler,被用于处理基于某个.aspx文件的请求.我们可以通过H ...
- 大数据导入Excel
在平时的项目中,将数据导出到Excel的需求是很常见的,在此对一些常见的方法做以总结,并提供一种大数据量导出的实现. OLEDB 使用OLEDB可以很方便导出Excel,思路很简单,处理时将Exc ...
- 4.0之后的hibernate获取sessionFactory
static{ Configuration config=new Configuration().configure(); ServiceRegistry resgistry = new Servic ...
- marginCollapse之兄弟关系的DIV
废话不说,直接上图 基本代码如下: 效果图如下: 给两个div分别加marginBottom和marginTop看一下效果 实际效果如下: 我们可以看出两个div之间的距离并不是50+50,而是只显示 ...
- 【转】使用Xcode和Instruments调试解决iOS内存泄露
原文网址:http://blog.csdn.net/totogo2010/article/details/8233565 虽然iOS 5.0版本之后加入了ARC机制,由于相互引用关系比较复杂时,内存泄 ...
- 如何制作和部署war包
通常的网站,很多是以war包形式发布的下边介绍如何自行制作war包 首先要求制作war包的环境安装j2sdk-1.4.2以上版本比如,安装了Plesk的服务器,就都已经具有了j2sdk切换到j2sdk ...
- Event/window.Event属性和方法
type:事件的类型,如onlick中的click:srcElement/target:事件源,就是发生事件的元素:button:声明被按下的鼠标键,整数,1代表左键,2代表右键,4代表中键,如果按下 ...
- C#中的选择查询相关
看代码实现: using System; using System.Collections.Generic; using System.Linq; using System.Text; using S ...
- 点击图片名,让图片在pictureBox中显示 z
public string filepath; public Form1() { InitializeComponent(); } private void button1_Click(object ...
- bzoj1036 树的统计Count
第一次写链剖,于是挑了个简单的裸题写. 以下几点要注意: 1.链剖中的height是从根到该店经过的轻边个数 2.分清num与sum..... #include<cstdio> #incl ...