Commit 6f871788 authored by 18손재민's avatar 18손재민

코드 간략화

parent 2d389e71
...@@ -2,7 +2,10 @@ class WordObject ...@@ -2,7 +2,10 @@ class WordObject
{ {
constructor(text) constructor(text)
{ {
this.generationCode = WordSpace.nextWordCode++;
this.wordText = text; this.wordText = text;
//this.wordText = Input.removeConVow(text);
this.wordTyping = (function(_wordText) this.wordTyping = (function(_wordText)
{ {
var temp = 0; var temp = 0;
...@@ -23,17 +26,27 @@ class WordObject ...@@ -23,17 +26,27 @@ class WordObject
_wordGrade == 1 ? 7 : 10; _wordGrade == 1 ? 7 : 10;
return temp; return temp;
})(this.wordGrade); })(this.wordGrade);
//alert("wordTyping : " + this.wordTyping + '\n' + "wordGrade : " + this.wordGrade + '\n' + "wordWeight : " + this.wordWeight + '\n'); //console.log("wordTyping : " + this.wordTyping + '\n' + "wordGrade : " + this.wordGrade + '\n' + "wordWeight : " + this.wordWeight + '\n');
} }
generate(scene) instantiate(scene)
{ {
var randomX = Phaser.Math.Between(100, 500); var randomX = Phaser.Math.Between(100, 700);
this.physicsObj = scene.physics.add.sprite(randomX, 100, 'wordBackground').setScale(0.5); 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 = scene.add.text(randomX, 100, this.wordText, {fontFamily: '"궁서", 궁서체, serif'}).setColor('#000000');
this.wordObj.setOrigin(0.5,0.5); this.wordObj.setOrigin(0.5,0.5);
} }
destroy()
{
this.wordObj.destroy();
const groupIdx = WordSpace.wordGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this);
if (groupIdx > -1) WordSpace.wordGroup.splice(groupIdx, 1);
const forceIdx = WordSpace.wordForcedGroup.findIndex(function(item) {return this.isEqualObject(item.generationCode)}, this);
if (forceIdx > -1) WordSpace.wordForcedGroup.splice(forceIdx, 1);
WordSpace.wordPhysicsGroup.remove(this.physicsObj, true, true);
}
attract(wordSpeed) attract(wordSpeed)
{ {
var dist = Phaser.Math.Distance.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y); var dist = Phaser.Math.Distance.Between(this.physicsObj.x, this.physicsObj.y, WordSpace.gravityPoint.x, WordSpace.gravityPoint.y);
...@@ -42,30 +55,9 @@ class WordObject ...@@ -42,30 +55,9 @@ class WordObject
this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y); this.wordObj.setPosition(this.physicsObj.x, this.physicsObj.y);
} }
getWordWeight() getWordWeight() { return this.wordWeight; }
{
return this.wordWeight;
}
removeConVow(_wordText) isEqualObject(_generationCode) { return _generationCode === this._generationCode; }
{
var temp = 0;
for(var i = 0; i < _wordText.length; i++)
{
}
return temp;
}
//***********ToDo*************
isEqual(inputWord)
{
if(inputWord === this.wordText)
{
this.destroy();
}
}
//****************************
} }
function firstSound(charText) function firstSound(charText)
......
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