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的的一个抽象子 ...
随机推荐
- POJ 3211 Washing Clothes【01背包】
题意:给出n种颜色,m件衣服,再分别给出m件衣服的颜色,和洗所需要的时间,dearboy和他的妹子一起洗衣服,且同种颜色的衣服不能同时洗,也不能两个人同时洗一件衣服,问洗完这m件衣服至少需要的时间 先 ...
- OpenStack (1) - Keystone OpenStack Identity Service
echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/grizzly main >> /etc ...
- C#中的lock关键字;就是lock住一个大家都共同访问的(静态static的)东东就行了
public class ChatService : IChat //继承IChat接口或者说IChat的实现类 { //定义一个静态对象用于线程部份代码块的锁定,用于lock操作 private s ...
- Maven之 环境搭建
这几天开始了maven的学习,看了孔浩老师的视频(http://pan.baidu.com/s/1o7bg2h0),以及黄勇大牛的博客(http://my.oschina.net/huangyong/ ...
- WMware 10 Ubuntu 12.04 进入Unity模式
/********************************************************************* * WMware 10 Ubuntu 12.04 进入Un ...
- Qt QGroupBox StyleSheet 边框设置
/**************************************************************************** * Qt QGroupBox StyleSh ...
- shell 括号学习
http://blog.csdn.net/tttyd/article/details/11742241 http://tldp.org/LDP/abs/html/loops1.html
- sound tips
ASaudio&SoundAS 两个开源项目阅读: ASaudio&SoundAS 都是比较小巧的声音控制,但似乎都不能直接拿到项目只直接使用. ASaudio ASaudio的Tra ...
- Aviary 滤镜 教程 照片编辑器
Aviary是一个国外的非常强大的照片编辑器,各种功能,但是是以静态库的形式存在的,不开源,但是很好用. 1.到官网上面下载sdk https://github.com/AviaryInc/Mobil ...
- HDU5808Price List Strike Back (BestCoder Round #86 E) cdq分治+背包
严格按题解写,看能不能形成sum,只需要分割当前sum怎么由两边组成就好 #include <cstdio> #include <cstring> #include <c ...