Commit 6150db4b authored by 18신대성's avatar 18신대성 Committed by 18류지석

메뉴씬 만듬

parent ec721f06
var BackGround = BackGround || {}
BackGround.isImageLoaded = false;
BackGround.brainGroup = null;
BackGround.loadImage = function(scene)
{
if (!this.isImageLoaded)
{
scene.load.image('brainGround0', 'assets/placeholder/playback.png');
}
scene.load.image('brainGround', 'assets/placeholder/playback.png');
scene.load.image('menuBackground', 'assets/placeholder/menuBackground.png')
}
BackGround.drawBrain = function(scene)
{
brains = scene.add.sprite(640, 360, 'brainGround0').setDisplaySize(1282, 722).setDepth(1);
brains = scene.add.sprite(640, 360, 'brainGround').setDisplaySize(1282, 722).setDepth(1);
}
BackGround.drawMenu = function(scene)
{
scene.add.sprite(640, 360, 'menuBackground').setDisplaySize(1282, 722).setDepth(1);
}
\ No newline at end of file
......@@ -11,6 +11,23 @@ Input.maxInput = 5;
Input.attackMode = false;
Input.attackOption = null;
Input.gameSceneEnterReaction = function()
{
Input.convInput = Input.removeConVow(Input.convInput);
if (Input.attackMode) WordSpace.attack(Input.convInput, Input.attackOption.wordGrade);
else WordSpace.findWord(Input.convInput);
WordSpace.resetGameOverTimer();
Input.reset();
}
Input.menuSceneEnterReaction = function()
{
Input.convInput = Input.removeConVow(Input.convInput);
console.log('닉네임은 ' + Input.convInput);
Input.reset();
game.scene.start('gameScene');
game.scene.remove('menuScene');
}
Input.reset = function()
{
Input.input = [];
......@@ -275,7 +292,7 @@ Input.removeConVow = function(_wordText)
Input.inputField =
{
generate: function(scene)
generate: function(scene, enterCallback)
{
this.background = scene.add.sprite(640, 550, 'inputfield').setDepth(10);
this.text = scene.add.text(640, 550, "안녕하세요", {font: '25pt 궁서'}).setOrigin(0.5, 0.5).setColor('#000000').setDepth(10);
......@@ -293,14 +310,7 @@ Input.inputField =
Input.inputField.text.setText(Input.convInput);
}
});
scene.input.keyboard.on('keydown-ENTER', function()
{
Input.convInput = Input.removeConVow(Input.convInput);
if (Input.attackMode) WordSpace.attack(Input.convInput, Input.attackOption.wordGrade);
else WordSpace.findWord(Input.convInput);
WordSpace.resetGameOverTimer();
Input.reset();
});
scene.input.keyboard.on('keydown-ENTER', enterCallback);
// upside 10 keys
scene.input.keyboard.on('keydown-Q', function() {Input.pushInput('')});
scene.input.keyboard.on('keydown-W', function() {Input.pushInput('')});
......
......@@ -11,12 +11,14 @@ var menuScene = new Phaser.Class(
preload: function()
{
//Input.inputField.loadImage(this);
Input.inputField.loadImage(this);
BackGround.loadImage(this);
},
create: function()
{
//Input.inputField.generate(this);
Input.inputField.generate(this, Input.menuSceneEnterReaction);
BackGround.drawMenu(this);
},
update: function()
......@@ -51,7 +53,7 @@ var gameScene = new Phaser.Class(
WordSpace.wordPhysicsGroup = this.physics.add.group();
Input.inputField.generate(this);
Input.inputField.generate(this, Input.gameSceneEnterReaction);
WordSpace.attackGauge.generate(this);
WordSpace.spaceInitiate(this);
......
......@@ -9,7 +9,7 @@ var config = {
}
},
backgroundColor: Phaser.Display.Color.GetColor(0,0,0),
scene: [ gameScene, menuScene ]
scene: [ menuScene, gameScene ]
};
var game = new Phaser.Game(config)
......@@ -25,31 +25,31 @@ socket.on('idSet', function(msg) // {str, num}
});
//test
window.addEventListener("message", function(event)
{
/*
window.addEventListener("message", function (event) {
var sub = 0;
if(event.data == "tick"){
if(window.lafcb)
if((new Date().getTime()/1000) - window.lafcb.started > 0.5){
window.lafcb.func(new Date().getTime()+16)
if (event.data == "tick") {
if (window.lafcb)
if ((new Date().getTime() / 1000) - window.lafcb.started > 0.5) {
window.lafcb.func(new Date().getTime() + 16)
window.lafcb = null;
}
var i = window.timeouts.length;
while (i--) {
if(window.timeouts[i].ran){
window.timeouts.splice(i,1);
if (window.timeouts[i].ran) {
window.timeouts.splice(i, 1);
}
}
var i = window.timeouts.length;
while (i--) {
if(new Date().getTime() - window.timeouts[i].started >= window.timeouts[i].delay && window.timeouts[i]){
if (new Date().getTime() - window.timeouts[i].started >= window.timeouts[i].delay && window.timeouts[i]) {
window.timeouts[i].func();
window.timeouts[i].ran = true;
}
}
for(var i in window.intervals){
for (var i in window.intervals) {
var currTime = new Date().getTime();
if(currTime - window.intervals[i].last >= window.intervals[i].delay && window.intervals[i]){
if (currTime - window.intervals[i].last >= window.intervals[i].delay && window.intervals[i]) {
window.intervals[i].last = currTime;
window.intervals[i].func();
}
......@@ -57,63 +57,63 @@ window.addEventListener("message", function(event)
window.postMessage('tick', '*');
}
}, false);
(function(context) {
'use strict';
(function (context) {
'use strict';
window.lafcb = null;
context.timeouts = [];
context.intervals = [];
var lastTime = new Date().getTime();
context.old = {};
old.setTimeout = (i,ii)=> context.setTimeout(i,ii);
old.setInterval = (i,ii) =>context.setInterval(i,ii);
old.clearTimeout = (i) =>context.clearTimeout(i);
old.clearInterval = (i) =>context.clearInterval(i);
if(typeof(context.postMessage) == 'function'){
context.setTimeout = function(fn, millis) {
var id = timeouts.length
timeouts[id] = {id: id,func: fn, delay: millis,started: new Date().getTime()};
old.setTimeout = (i, ii) => context.setTimeout(i, ii);
old.setInterval = (i, ii) => context.setInterval(i, ii);
old.clearTimeout = (i) => context.clearTimeout(i);
old.clearInterval = (i) => context.clearInterval(i);
if (typeof (context.postMessage) == 'function') {
context.setTimeout = function (fn, millis) {
var id = timeouts.length
timeouts[id] = { id: id, func: fn, delay: millis, started: new Date().getTime() };
return id;
};
context.clearTimeout = function(cancel) {
for(var i in timeouts){
if(timeouts[i].id == cancel){
timeouts.splice(i,1);
context.clearTimeout = function (cancel) {
for (var i in timeouts) {
if (timeouts[i].id == cancel) {
timeouts.splice(i, 1);
break;
}
}
};
context.setInterval = function(fn, delay ) {
intervals[intervals.length] = {func: fn, delay: delay,last: new Date().getTime()};
return intervals[intervals.length-1];
context.setInterval = function (fn, delay) {
intervals[intervals.length] = { func: fn, delay: delay, last: new Date().getTime() };
return intervals[intervals.length - 1];
};
context.clearInterval = function(cancel) {
for(var i in intervals){
if(intervals[i] == cancel){
intervals.splice(i,1);
context.clearInterval = function (cancel) {
for (var i in intervals) {
if (intervals[i] == cancel) {
intervals.splice(i, 1);
break;
}
}
};
}
context.requestAnimationFrame = function( callback, element ) {
lafcb = {started: new Date().getTime()/1000,func: callback};
context.requestAnimationFrame = function (callback, element) {
lafcb = { started: new Date().getTime() / 1000, func: callback };
var currTime = new Date().getTime();
var timeToCall = 16;
var id = context.setTimeout( function() {
callback( currTime+timeToCall);
}, timeToCall );
var id = context.setTimeout(function () {
callback(currTime + timeToCall);
}, timeToCall);
return id;
};
context.cancelAnimationFrame = function( id ) {
lafcb
context.clearTimeout( id );
context.cancelAnimationFrame = function (id) {
lafcb
context.clearTimeout(id);
};
context.addEventListener("load",function(){
if(typeof(context.postMessage) == 'function'){
context.addEventListener("load", function () {
if (typeof (context.postMessage) == 'function') {
context.postMessage('tick', '*');
}else{
} else {
context.setTimeout = old.setTimeout
context.setInterval = old.setInterval
context.clearTimeout = old.clearTimeout
......@@ -121,4 +121,4 @@ window.addEventListener("message", function(event)
alert("Your browser does not support postMessage. Sorry but you will be forced to default to the standard setInterval and setTimeout functions. This means you may experience pauses in your game when you navigate away from the tab it is playing in.");
}
});
})(this);
})(this);*/
\ No newline at end of file
......@@ -48,7 +48,7 @@ GameServer.makeRoom = function()
var roomOption =
{
roomNum: GameServer.nextRoomNumber++,
maxPlayer: 25,
maxPlayer: 3,
currentPlayer: []
}
this.playingRoom.push(roomOption);
......@@ -110,6 +110,8 @@ io.on('connection', function(socket)
{
console.log('client disconnected, id: ' + GameServer.currentPlayer[idxToDel].id + ', reason: ' + reason);
GameServer.currentPlayer.splice(idxToDel, 1);
// 룸에서도 제거
// 모두에게 삭제했다고 보내기
}
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment