Commit d28c495c authored by 18신대성's avatar 18신대성 Committed by 16이지혜

단어가 주기적으로 생성되게 함.

WordSpace.resetCycle로 주기 변경 가능
parent 347e52db
......@@ -28,8 +28,8 @@ class WordObject
generate(scene)
{
var randomX = Phaser.Math.Between(100, 500);
this.physicsObj = scene.physics.add.sprite(randomX, 100, 'wordBackground').setScale(0.5);
var randomX = Phaser.Math.Between(100, 700);
this.physicsObj = scene.physics.add.sprite(randomX, 100, 'wordBackground').setScale(0.3);
this.wordObj = scene.add.text(randomX, 100, this.wordText, {fontFamily: '"궁서", 궁서체, serif'}).setColor('#000000');
this.wordObj.setOrigin(0.5,0.5);
}
......
......@@ -7,6 +7,48 @@ WordSpace.wordPhysicsGroup = null;
WordSpace.gravityPoint = {x: 400, y: 300};
WordSpace.wordCycle = null;
WordSpace.resetCycle = function(scene, _delay)
{
if (this.wordCycle != null)
{
this.wordCycle = this.wordCycle.reset(
{
delay: _delay,
callback: function()
{
word = new WordObject("솽젠커");
word.generate(this);
WordSpace.wordGroup.push(word);
this.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
},
callbackScope: scene,
loop: true
}
);
}
else
{
this.wordCycle = scene.time.addEvent(
{
delay: _delay,
callback: function()
{
word = new WordObject("솽젠커");
word.generate(this);
WordSpace.wordGroup.push(word);
this.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup);
this.physics.add.collider(word.physicsObj, BackGround.brainGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
},
callbackScope: scene,
loop: true
}
);
}
}
WordSpace.loadImage = function(scene)
{
if (!this.isImageLoaded)
......
......@@ -32,22 +32,7 @@ function create()
BackGround.drawBrain(this);
WordSpace.wordGroup = [];
WordSpace.wordPhysicsGroup = this.physics.add.group();
this.time.addEvent(
{
delay: 2000,
callback: function()
{
word = new WordObject("솽젠커");
word.generate(this);
WordSpace.wordGroup.push(word);
this.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
},
callbackScope: this,
repeat: 10
}
);
WordSpace.resetCycle(this, 2000);
}
function update()
......
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