Add: typing test for word, sentence

This commit is contained in:
2018-06-07 11:07:53 +09:00
parent 670d48cbc7
commit 70ce70a148
27 changed files with 2011 additions and 3 deletions
+89
View File
@@ -0,0 +1,89 @@
/////////////////////////////
// Typing Test
class Test {
create() {
this.game.stage.backgroundColor = '#4d4d4d';
sessionStorageManager.isNewBestRecrd = false;
// top
let backButton = new BackButton( () => {
sessionStorageManager.resetPlayingAppData();
location.href = '../../web/client/menu_app.html';
});
let fullscreenButton = new FullscreenButton(this.game);
// waiting room
this.game.add.graphics()
.beginFill(0xffffff, 0.1)
.drawRect(0, 100, game.world.width, 100);
// contents
// bottom
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
screenBottom.printBottomLeftTextWithBestRecord(sessionStorageManager.bestRecord);
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
screenBottom.printBottomRightText(sessionStorageManager.playerName);
this.startGame();
// this.countDown();
}
initListeners() {
}
/*
countDown() {
const 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;
let 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() {
}
gameOver() {
let gameOverText = new GameOverText();
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
}
goResult() {
location.href = '../../web/client/result.html';
}
}
+93
View File
@@ -0,0 +1,93 @@
/////////////////////////////
// Loading
// var x = 32;
// var y = 80;
class Loading {
preload() {
// this.game.load.image('loadingbar', './image/phaser.png');
}
create() {
// let userID = sessionStorage.getItem("UserID");
// console.log("userID : " + userID);
// this.game.stage.backgroundColor = '#4d4d4d';
// // Progress report
// this.textProgress = game.add.text(game.world.centerX, 100, '로딩중 . . .', textStyleBasic);
// this.textProgress.anchor.setTo(0.5, 0.4);
// this.textProgress.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// // Preload bar
// this.preloadBar = this.add.sprite(game.world.centerX, game.world.centerY, 'loadingbar');
// this.preloadBar.anchor.setTo(0.5);
// this.preloadBar.alpha = 0;
this.game.load.onFileComplete.add(this.fileComplete, this);
this.game.load.onLoadComplete.add(this.loadComplete, this);
this.startLoading();
}
startLoading() {
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('a', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('b', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('c', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('d', '../../../resources/image/icon/fullscreen_white.png');
// this.game.load.image('a', './image/phaser.png');
// this.game.load.image('b', './image/phaser.png');
// this.game.load.image('c', './image/phaser.png');
// this.game.load.image('d', './image/phaser.png');
// this.game.load.image('e', './image/phaser.png');
// this.game.load.image('g', './image/phaser.png');
// this.game.load.image('e', './image/phaser.png');
// this.game.load.image('f', './image/phaser.png');
// this.game.load.image('g', './image/phaser.png');
// this.game.load.image('h', './image/phaser.png');
// this.game.load.image('phaser', './image/phaser.png');
// this.game.load.spritesheet('button', './image/button_basic.png', 200, 100);
// this.game.load.image('star', './image/star_particle.png');
// this.game.load.image('medal_gold', './image/medal_gold.png');
// this.game.load.image('medal_silver', './image/medal_silver.png');
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
this.game.load.start();
}
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
// this.preloadBar.alpha = progress / 100;
// console.log('progress : ' + progress);
// text.setText("File Complete: " + progress + "% - " + totalLoaded + " out of " + totalFiles);
// var newImage = game.add.image(x, y, cacheKey);
// newImage.scale.set(0.3);
// x += newImage.width + 20;
// if (x > 700)
// {
// x = 32;
// y += 332;
// }
}
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
// this.preloadBar.alpha = 1;
if(isDebugMode()) {
this.state.start('Test');
return;
}
this.state.start('Test');
// this.startMenu();
// this.startTypingTestStage();
// this.startTypingTestResult();
}
}
+16
View File
@@ -0,0 +1,16 @@
/////////////////////////////
// Main game
const CONTENT_ID = "Typing Test";
let game = new Phaser.Game(
GAME_SCREEN_SIZE.x, GAME_SCREEN_SIZE.y,
Phaser.CANVAS, CONTENT_ID,
this, false, false
);
game.state.add('Loading', Loading);
game.state.start('Loading');
game.state.add('Test', Test);
// game.state.add('Menu', Menu);