Commit 1fad648a authored by 18신대성's avatar 18신대성

Merge branch 'test1'

# Conflicts:
#	js/WordObject.js
parents c230443d 6d3b8c47
......@@ -19,12 +19,15 @@ class WordObject
WordSpace.setGameOverTimer();
console.log("Total weight : " + WordSpace.totalWeight);
//console.log("wordTyping : " + this.wordTyping + '\n' + "wordGrade : " + this.wordGrade + '\n' + "wordWeight : " + this.wordWeight + '\n');
this.wordSpeed = 1;
//alert("wordTyping : " + this.wordTyping + '\n' + "wordGrade : " + this.wordGrade + '\n' + "wordWeight : " + this.wordWeight + '\n');
}
instantiate(scene)
{
var randomX = Phaser.Math.Between(100, 700);
this.physicsObj = scene.physics.add.sprite(randomX, 100, 'wordBackground').setScale(0.3);
this.physicsObj.body.bounce.set(0.5);
this.wordObj = scene.add.text(randomX, 100, this.wordText, {fontFamily: '"궁서", 궁서체, serif'}).setColor('#000000');
this.wordObj.setOrigin(0.5,0.5);
}
......@@ -39,12 +42,12 @@ class WordObject
if (forceIdx > -1) WordSpace.wordForcedGroup.splice(forceIdx, 1);
WordSpace.wordPhysicsGroup.remove(this.physicsObj, true, true);
}
attract(wordSpeed)
attract()
{
var dist = Phaser.Math.Distance.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y);
var angle = Phaser.Math.Angle.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y);
this.physicsObj.setVelocity(dist * Math.cos(angle) * wordSpeed, dist * Math.sin(angle) * wordSpeed);
this.physicsObj.setVelocity(dist * Math.cos(angle) * this.wordSpeed, dist * Math.sin(angle) * this.wordSpeed);
this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y);
}
......
......@@ -91,7 +91,11 @@ WordSpace.generateWord = function(scene)
word.instantiate(scene);
WordSpace.wordGroup.push(word);
WordSpace.wordForcedGroup.push(word);
scene.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup);
word.physicsObj.topObj = word;
scene.physics.add.collider(word.physicsObj, WordSpace.wordPhysicsGroup, function(object1)
{
if (object1.topObj.wordSpeed > 0.5) object1.topObj.wordSpeed = 0.05;
});
scene.physics.add.collider(word.physicsObj, BackGround.brainGroup);
WordSpace.wordPhysicsGroup.add(word.physicsObj);
}
......
......@@ -39,7 +39,7 @@ function update()
{
WordSpace.wordForcedGroup.forEach(function(element)
{
element.attract(0.3);
element.attract();
});
}
......
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