tm.display.TriangleShapeを継承
tm.define("Player", { // クラス名
superClass: "[[tm.display.TriangleShape]]", // 継承するtmlib.jsクラス
init: function(){ // クラスメソッド
this.superInit(); // 親クラスのInit関数呼び出し
},
});
tm.display.AnimationSpriteを継承
tm.define("user.Player", {
superClass: "[[tm.display.AnimationSprite]]",
init: function(){
var ss = tm.asset.SpriteSheet({
image: "chick",// ローディングクラスで読み込んだASSETS画像のラベル名
frame: {
width: 32, // スプライト幅
height: 32, // スプライト高さ
count: 64 //スプライトコマ数
},
"animations": {
// Walk
// ひよこ
chick_walk: {
frames: [1, 2, 3, 2],
next: "chick_walk",
frequency: 4
},
play: {
frames: [0, 1, 2, 2, 3, 4, 5],
next: "play",
frequency: 2,
},
},
});
this.superInit(ss);
this.direct = "left";
this.isMobile = tm.isMobile;
this.vx = -4;
},
update: function(app){
if(app.frame % 2 == 0) {
this.frameIndex++;
}
// move
this.x += this.vx;
if(this.x < 0) {
this.x = 0;
this.vx *= -1;
this.scaleX *= -1;
} else if(this.x > SCREEN_WIDTH) {
this.x = SCREEN_WIDTH;
this.vx *= -1;
this.scaleX *= -1;
}
},
});
最終更新:2014年07月14日 17:37