Add: dodge app
This commit is contained in:
@@ -0,0 +1,137 @@
|
||||
var Game = {
|
||||
|
||||
create: function() {
|
||||
this.game.stage.backgroundColor = "#000000"; // '#4d4d4d';
|
||||
|
||||
this.scoreManager = new ScoreManager();
|
||||
|
||||
sessionStorageManager.setIsNewAppHighestRecord(false);
|
||||
|
||||
var experienceAppTimer = new ExperienceAppTimer();
|
||||
experienceAppTimer.setTimeOverListener(
|
||||
(function() { this.gameOver(); }).bind(this)
|
||||
);
|
||||
|
||||
// keyboard shortcut
|
||||
this.keyboardShortcut = new KeyboardShortcut();
|
||||
this.keyboardShortcut.addCallback(
|
||||
Phaser.KeyCode.ESC, // keyCode
|
||||
null, // keyDownHandler
|
||||
(function() { this.back(); }).bind(this), // keyUpHandler
|
||||
"dodge" // callerClassName
|
||||
);
|
||||
|
||||
// game stage
|
||||
var stars = game.add.group();
|
||||
|
||||
for (var i = 0; i < 128; i++)
|
||||
{
|
||||
var randomY = game.rnd.integerInRange(60, GAME_SCREEN_SIZE.y - 80);
|
||||
stars.create(game.world.randomX, randomY, 'star');
|
||||
}
|
||||
|
||||
|
||||
|
||||
// contents
|
||||
this.spaceship = new Spaceship();
|
||||
|
||||
this.aliens = [];
|
||||
for(var i = 0; i < 50; i++) {
|
||||
var alien = new Alien(this.spaceship);
|
||||
this.aliens.push(alien);
|
||||
}
|
||||
|
||||
|
||||
// top ui
|
||||
var screenTopUI = new ScreenTopUI();
|
||||
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
||||
screenTopUI.makeFullScreenButton();
|
||||
|
||||
var scoreBoard = new ScoreBoard();
|
||||
this.scoreManager.addOnChangeScoreListener( function(score) {
|
||||
sessionStorageManager.setRecord(score);
|
||||
scoreBoard.printScore(NumberUtil.numberWithCommas(score));
|
||||
});
|
||||
this.scoreManager.addOnChangeHighScoreListener( function(highScore) {
|
||||
// console.log(highScore);
|
||||
// sessionStorageManager.setAppHighestRecord(highScore);
|
||||
sessionStorageManager.setIsNewBestRecrd(true);
|
||||
// screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
|
||||
});
|
||||
|
||||
|
||||
// bottom ui
|
||||
var screenBottomUI = new ScreenBottomUI();
|
||||
screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
|
||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||
|
||||
|
||||
this.startGame();
|
||||
// this.countDown();
|
||||
},
|
||||
|
||||
|
||||
back: function() {
|
||||
sessionStorageManager.resetPlayingAppData();
|
||||
location.href = '../../web/client/menu_app.html';
|
||||
},
|
||||
|
||||
initListeners: function() {
|
||||
},
|
||||
|
||||
/*
|
||||
countDown() {
|
||||
var style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
this.countDownText = game.add.text(0, 0, "", style);
|
||||
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
|
||||
this.countDownText.stroke = "#333";
|
||||
this.countDownText.strokeThickness = 50;
|
||||
|
||||
this.countDownNumber = 3;
|
||||
if(isDebugMode())
|
||||
this.countDownNumber = 1;
|
||||
this.tweenCountDown();
|
||||
}
|
||||
|
||||
tweenCountDown() {
|
||||
if(this.countDownNumber === 0) {
|
||||
this.startGame();
|
||||
return;
|
||||
}
|
||||
|
||||
this.countDownText.text = this.countDownNumber.toString();
|
||||
this.countDownText.alpha = 1;
|
||||
|
||||
var countDownTween = game.add.tween(this.countDownText);
|
||||
countDownTween.to( { alpha: 0 }, 1000, Phaser.Easing.Linear.None, true);
|
||||
countDownTween.onComplete.add(this.tweenCountDown, this);
|
||||
|
||||
this.countDownNumber--;
|
||||
}
|
||||
*/
|
||||
|
||||
startGame: function() {
|
||||
},
|
||||
|
||||
gameOver: function() {
|
||||
var gameOverText = new GameOverText();
|
||||
|
||||
game.time.events.add(GAME_OVER_WAIT_TIME_MS, this.goResult, this);
|
||||
},
|
||||
|
||||
goResult: function() {
|
||||
location.href = '../../web/client/result.html';
|
||||
},
|
||||
|
||||
getScore: function() {
|
||||
return (this.alienTimer.activatedAlienIndex) * 2;
|
||||
},
|
||||
|
||||
onAlienEscaped: function() {
|
||||
this.heartManager.breakHearts(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Game.GAME_OVER_WAIT_TIME_MS = 2000;
|
||||
Reference in New Issue
Block a user