Puppet.create("Monster", {
filename: "chara6.png",
w: 32,
h: 32,
behavior: [{
init: function() {
this.frame = 52;
}
}, "standAlone",
{
sceneStart: function() {
this.interval = 30;
this.initialNumber = 10;
}
}, "tapMove",
"hitAndDie",
{
init: function() {
this.collision.push
("Skeleton");
}
}, {
hit: function(event) {
var other = event.other;
var Constructor =
enchant.puppet.Actor.constructors
["Skeleton"];
if (Constructor && (other instanceof
Constructor)) {
enchant.puppet.Theatre.instance.score +=
parseFloat(0) || 0;
}
}
}, {
enterframe: function(event) {
if (enchant.puppet.Theatre.instance.frame %
10 == 9) {
var Constructor =
enchant.puppet.Actor.constructors["Missile"];
if (Constructor) {
var x = this.x + this.width / 2 -
Constructor.definition.w / 2;
var y = this.y + this.height / 2 -
Constructor.definition.h / 2;
var puppet = new Constructor(x, y);
puppet.addBehavior();
}
this.cvsRender = function(ctx) {
var comp = ctx.globalCompositeOperation;
this.getConstructor().prototype.cvsRender.call
(this, ctx);
ctx.globalCompositeOperation =
"lighter";
this.getConstructor().prototype.cvsRender.call(this, ctx);
ctx.globalCompositeOperation = comp;
};
setTimeout(function() {
delete this.cvsRender;
}.bind(this), 100);
} else {
}
}
}, {
init: function() {
this.collision.push
("Skeleton");
}
}, {
hit: function(event) {
var other = event.other;
var Constructor =
enchant.puppet.Actor.constructors
["Skeleton"];
if (Constructor && (other instanceof
Constructor)) {
var Constructor =
enchant.puppet.Actor.constructors["ばくはつ"];
if (Constructor) {
var x = this.x + this.width / 2 -
Constructor.definition.w / 2;
var y = this.y + this.height / 2 -
Constructor.definition.h / 2;
var puppet = new Constructor(x, y);
puppet.addBehavior();
}
(function() {
var theatre =
enchant.puppet.Theatre.instance;
theatre.end(theatre.score, "score:
" + theatre.score);
}());
}
}
}]
});
Puppet.create("Skeleton", {
filename: "icon0.png",
w: 16,
h: 16,
behavior: [{
init: function() {
this.frame = 11;
}
}, "randomAppearTop",
{
sceneStart: function() {
this.interval = 5;
this.initialNumber = 10;
}
}, "zigzagX",
{
init: function() {
this.speed = 30;
}
}, "hitAndDie",
{
init: function() {
this.collision.push(
"Missile");
}
}, {
hit: function(event) {
var other = event.other;
var Constructor =
enchant.puppet.Actor.constructors["Missile"];
if (Constructor && (other instanceof
Constructor)) {
enchant.puppet.Theatre.instance.score +=
parseFloat(10) || 0;
}
}
}, {
init: function() {
this.collision.push
("Missile");
}
}, {
hit: function(event) {
var other = event.other;
var Constructor =
enchant.puppet.Actor.constructors["Missile"];
if (Constructor && (other instanceof
Constructor)) {
var Constructor =
enchant.puppet.Actor.constructors["ばくはつ"];
if (Constructor) {
var x = this.x + this.width / 2 -
Constructor.definition.w / 2;
var y = this.y + this.height / 2 -
Constructor.definition.h / 2;
var puppet = new Constructor(x, y);
puppet.addBehavior();
}
}
}
}]
});
Puppet.create("ばくはつ", {
filename: "effect0.gif",
w: 16,
h: 16,
behavior: ["smaller",
{
init: function(event) {
setTimeout((function() {
if (typeof this.addBehavior ===
"function") {
this.addBehavior("die");
}
}).bind(this), 2 * 1000);
}
}]
});
Puppet.create("Missile", {
filename: "icon0.png",
w: 16,
h: 16,
behavior: [{
init: function() {
this.frame = 60;
}
}, "moveUp",
{
init: function() {
this.speed = 300;
}
}]
});
MutableSignBoard.create("TimerBoard", {
t: "30sec",
count: 30,
behavior: [{
sceneStart: function() {
this.startPin = [
[theatre.width - 80, 0]
];
}
}, {
init: function() {
this.signalDispatched = false;
this.count = 30;
}
}, {
enterframe: function() {
var theatre = enchant.puppet.Theatre.instance;
if (!this.startTime) {
this.startTime = Date.now();
}
this.timeLeft = this.count - ~~ ((Date.now() - this.startTime) * 0.001);
if (this.timeLeft >= 0) {
this.text = this.timeLeft + "sec";
this.x = theatre.width - this.width;
} else if (!this.signalDispatched) {
theatre.dispatchSignal(enchant.puppet.Actor, "timeup");
this.signalDispatched = true;
}
}
}, "standAlone",
{
timeup: function(event) {
(function() {
var theatre = enchant.puppet.Theatre.instance;
theatre.end(theatre.score, "score: " + theatre.score);
}());
}
}]
});
MutableSignBoard.create("ScoreBoard", {
t: "SCORE:0",
score: 0,
behavior: [{
sceneStart: function() {
this.startPin = [
[0, 0]
];
}
}, {
init: function() {
enchant.puppet.Theatre.instance.score = 0;
}
}, {
enterframe: function() {
this.text = "SCORE:" + enchant.puppet.Theatre.instance.score;
}
}, "standAlone", ]
});
enchant.puppet.Theatre.changeScreen("spacebg.png");
Monster, フレーム52、ひとつだけでる、タップしたところに位置変更
全方向、Skeleton消える0、時間が進んだ、10コマに一度、Missile、
光る、Skeleton、ばくはつ
Skeleton、フレーム11、上からたくさん出てくる5、ジグザグに移動横、
スピード30、Missile消える10、Missileばくはつ
Missile、フレーム60、1方向に移動上、スピード300、
ばくはつ、小さくなる全方向、画面に現れた、2、消える
カウントダウン30、タイマーが終了した
宇宙

