2007년 12월 21일
자바스크립트로 만드는 객체지향 게임 - 불꽃 클래스
불꽃 클래스는 따로 동작하는 것이 없으며, 아래로 떨어지기만 합니다.
불꽃 클래스는 아래와 같습니다.
/* 불꽃클래스*/
$class({
CFire : {
sprite : null,
fireShape : 0,
lane : null,
bShow : true,
/* 불꽃스프라이트를생성하고애니메이션을시작한다*/
init : function (lane) {
this.lane=lane;
this.sprite = $factory.get(CSpriteBase).get(1,lane.element);
this.sprite.setPos(0,0,lane.element);
this.fireShape = this.sprite.getShape();
this.show();
this.animate();
},
/* 불꽃을보인다*/
show : function() {
this.bShow=true;
this.sprite.show();
},
/* 불꽃을숨긴다*/
hide : function() {
this.bShow=false;
this.sprite.hide();
},
/* 불꽃스프라이트이미지를주기적으로바꾸어애니메이션구현*/
animate : function() {
this.fireShape++;
if (this.fireShape>1) this.fireShape=0;
this.sprite.shape(this.fireShape);
if (this.bShow==true) window.setTimeout(this.animate.bind(this),400);
},
/* 불꽃을아래로한칸이동시킨다*/
moveDown : function() {
var pos = this.sprite.getPos();
pos.y+=29;
this.sprite.setPos(pos.x,pos.y);
}
}
});
# by | 2007/12/21 16:59 | SWAF - 응용 | 트랙백 | 덧글(0)




☞ 내 이글루에 이 글과 관련된 글 쓰기 (트랙백 보내기) [도움말]