1 var MovableStageObjectClass = function(stage)
3 MovableStageObjectClass.base.apply(this, [stage]);
5 this.movingSpeed = new Point2D(0, 0);
6 //2 * hysteresis >= movingFriction
\82Å
\82 \82é
\82±
\82Æ
\82ð
\90\84\8f§
\82·
\82é
\81B
7 //
\82»
\82¤
\82Å
\82È
\82¢
\8fê
\8d\87\81A
\96\80\8eC
\82Å
\82Ì
\8c¸
\91¬
\8cã
\82É
\8a®
\91S
\82É
\92â
\8e~
\82Å
\82«
\82È
\82¢
\89Â
\94\
\90«
\82ª
\82 \82é
\81B
8 this.movingFriction = 8000;
9 this.hysteresis = this.movingFriction/ 60;
10 this.xMaxSpeed = 5000;
13 }.extend(StageObject, {
15 if(this.movingSpeedX > this.xMaxSpeed) this.movingSpeedX = this.xMaxSpeed;
16 //if(this.movingSpeedY > this.yMaxSpeed) this.movingSpeedY = this.yMaxSpeed;
17 if(this.movingSpeedX < -this.xMaxSpeed) this.movingSpeedX = -this.xMaxSpeed;
18 //if(this.movingSpeedY < -this.yMaxSpeed) this.movingSpeedY = -this.yMaxSpeed;
20 //
\92ï
\8dR
\8f\88\97\9d
21 if(this.movingSpeed.x < -this.hysteresis){
22 this.movingSpeed.x += this.movingFriction / this.stage.manager.tickPerSecond;
23 } else if(this.movingSpeed.x > this.hysteresis){
24 this.movingSpeed.x -= this.movingFriction / this.stage.manager.tickPerSecond;
26 this.movingSpeed.x = 0;
30 this.movingSpeed.y += 300 / this.stage.manager.tickPerSecond;
32 //
\89^
\93®
\8f\88\97\9d
33 var col = this.moveTo(
34 this.origin.x + (this.movingSpeed.x / this.stage.manager.tickPerSecond),
35 this.origin.y + (this.movingSpeed.y / this.stage.manager.tickPerSecond)
38 //
\8fÕ
\93Ë
\8e\9e\82Ì
\89^
\93®
\83G
\83l
\83\8b\83M
\81[
\8fÁ
\96Å
\90Ý
\92è
39 if(col & 1 != 0 && this.movingSpeed.x > 0) this.movingSpeed.x = 0;
40 if(col & 2 != 0 && this.movingSpeed.x < 0) this.movingSpeed.x = 0;
41 if(col & 4 != 0 && this.movingSpeed.y > 0) this.movingSpeed.y = 0;
42 if(col & 8 != 0 && this.movingSpeed.y < 0) this.movingSpeed.y = 0;
44 moveTo : function(x, y) {
45 //
\93\96\82½
\82è
\94»
\92è
\82Ì
\8eÀ
\91\95
46 this.stage.moveTo(this, x, y);
48 isCollided : function(obj, x, y)
50 //MovableStageObject
\82ª(x, y)
\82Ì
\82Æ
\82«
\91\8a\8eè
\82Ìobj
\82Æ
\8fÕ
\93Ë
\82·
\82é
\82©
\94»
\92è
51 if(obj instanceof BlockClass)
53 var ox = obj.origin.x, oy = obj.origin.y;
54 return x + 32 >= ox && x <= ox + 32 && y + 32 >= oy && y <= oy + 32;
60 //child : CharacterClass