开始画面

游戏画面

代码

<!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 教程之八 创造场景的更多相关文章

  1. iOS Sprite Kit教程之滚动场景

    iOS Sprite Kit教程之滚动场景 滚动场景 在很多的游戏中,场景都不是静止的,而是滚动的,如在植物大战僵尸的游戏中,它的场景如图2.26所示. 图2.26  植物大战僵尸 在图2.26中,用 ...

  2. 超详细实战教程丨多场景解析如何迁移Rancher Server

    本文转自Rancher Labs 作者介绍 王海龙,Rancher中国社区技术经理,负责Rancher中国技术社区的维护和运营.拥有6年的云计算领域经验,经历了OpenStack到Kubernetes ...

  3. Cocos2d-x 3.0final 终结者系列教程06-Director和场景跳转

    这些天互联网大事不少呀 1.逻辑思维分家(所谓合久必分,分久必合,实属正常.切行切珍惜吧) 2. 锤子手机开卖  (无论你买没买,反正我没买,作为多年Android开发的我深知说的亮点事实上在我看来都 ...

  4. ASP.NET MVC4 新手入门教程之八 ---8.向模式中添加验证

    在这本部分会将验证逻辑添加到Movie模式,和你会确保验证规则执行任何时候用户试图创建或编辑使用该应用程序的一部电影. 保持事物的干练性 ASP.NET MVC 的核心设计信条之一是 DRY(”Don ...

  5. (Python基础教程之八)Python中的list操作

    Python基础教程 在SublimeEditor中配置Python环境 Python代码中添加注释 Python中的变量的使用 Python中的数据类型 Python中的关键字 Python字符串操 ...

  6. qtp:vbs基础教程

    ◎Vbs脚本编程简明教程之中的一个-为什么要使用Vbs?  在Windows中,学习计算机操作或许非常easy,可是非常多计算机工作是反复性劳动,比如你每周或许须要对一些计算机文件进行复制.粘贴.改名 ...

  7. Vbs 脚本编程简明教程之一

    —为什么要使用 Vbs ? 在 Windows 中,学习计算机操作也许很简单,但是很多计算机工作是重复性劳动,例如你每周也许需要对一些计算机文件进行复制.粘贴.改名.删除,也许你每天启动 计算机第一件 ...

  8. mybatis 教程(mybatis in action)

    目录简介: 一:开发环境搭建二:以接口的方式编程 三:实现数据的增删改查 四:实现关联数据的查询 五:与spring3集成(附源码) 六:与Spring MVC 的集成 七:实现mybatis分页(源 ...

  9. VBS教程

    Vbs是一种Windows脚本,它的全称是:Microsoft Visual Basic Script Editon.(微软公司可视化BASIC脚本版),VBS是Visual Basic的的一个抽象子 ...

随机推荐

  1. OCJP考试介绍

    OCJP考试介绍 考试名称:SCJP / OCJP / 1Z0-851 考试时间:150分钟 考题题目:60道题 通过条件:大于等于61%的题目正确 考点查询:http://www.pearsonvu ...

  2. android事件系列-onTouch事件与手势操作

    提示记忆:应用流程:在Activity中对控件执行 view.setOnTouchListener( OnTouchListener i);实现里面的OnTouchListener 接口中的方法,重点 ...

  3. 图形编程(数值微分DDA)

    #include <iostream> #include <time.h> #include <stdio.h> #include <stdlib.h> ...

  4. ecshop 点购物车弹出提示框

    1.找到common.js在最下面输入以下代码 * 点击购物后弹出提示层 * Chen 2010.7.28 * 参数 cartinfo:购物车信息 */function openDiv_chen(ca ...

  5. (六) 语言模型 Language Madel 与 word2vec

    语言模型简介(Language Model) 简单的说,语言模型 (Language Model) 是用来计算一个句子出现概率的模型,假设句子  ,其中  代表句子中的第  个词语,则语句 W 以该顺 ...

  6. HDU 2026 首字母变大写

    #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int ma ...

  7. 【英语】Bingo口语笔记(35) - 常见单词结尾发音

  8. 【自动化测试】Selenium的智能等待

    dr.implicitly_wait(30) --- 智能等待 http://www.cnblogs.com/fnng/p/3214112.html =========== selenium 调用键盘 ...

  9. 锋利的jQuery读书笔记---jQuery中Ajax--序列化元素、Ajax全局事件

    serialize()方法: 作用于一个jQuery对象,它能够将DOM元素内容序列化为字符串,用于Ajax请求. <!DOCTYPE html> <html> <hea ...

  10. Android Studio Check for Update

    Android Studio 当前版本1.0.1, 官网新版本1.1.0, 通过 Check for Update...升级, 提示 Connection failed. Please check y ...