2 // グローバル名前空間にmainManagerがすでに存在する状況下で呼ばれる。
3 // 最初の行で新たなインスタンスを生成し、最後のreturnでそれを返す。
5 stage = new GameStage();
10 stage.runStage = function(){
11 //元々定義されていた、疑似スーパークラス(prototype)の関数を呼び出す。
12 GameStage.prototype.runStage.apply(this, []);
13 for(i = 0; i < 2; i++){
14 aCircle = new CharacterClass(this);
15 aCircle.origin.x = 16 + 16 * i;
16 aCircle.origin.y = 16 + 16 * i;
17 aCircle.frame.origin.x = - (8 + i);
18 aCircle.frame.origin.y = - (8 + i);
19 aCircle.frame.size.x = 2 * (8 + i);
20 aCircle.frame.size.y = 2 * (8 + i);
22 this.addStageObject(aCircle);
26 stage.drawBackground = function(){
27 this.mainContext.fillStyle = (["rgb(200,0,0)","rgb(0,200,0)","rgb(0,0,200)"])[this.manager.timeStamp / 1000 % 3];
28 this.mainContext.fillRect(0, 0, this.mainCanvas.width, this.mainCanvas.height);
29 this.collisionMapContext.clearRect(0, 0, this.collisionMapCanvas.width * 8, this.collisionMapCanvas.height * 8);
32 stage.timerTick = function(){
33 GameStage.prototype.timerTick.apply(stage, []);
34 if(this.manager.keyState.upArrow){
36 stage.eachStageObject(function(item){item.movingSpeed.y -= stage.moveForce; });
38 if(this.manager.keyState.downArrow){
40 stage.eachStageObject(function(item){item.movingSpeed.y += stage.moveForce;});
42 if(this.manager.keyState.leftArrow){
43 stage.eachStageObject(function(item){item.movingSpeed.x -= stage.moveForce;});
45 if(this.manager.keyState.rightArrow){
47 stage.eachStageObject(function(item){item.movingSpeed.x += stage.moveForce;});