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

word destroy 구현, 각 wordObj마다 개별 code를 가지게됨

parent 6a317860
......@@ -2,6 +2,8 @@ class WordObject
{
constructor(text)
{
this.generationCode = WordSpace.nextWordCode++;
this.wordText = text;
this.wordTyping = (function(_wordText)
{
......@@ -33,6 +35,17 @@ class WordObject
this.wordObj = scene.add.text(randomX, 100, this.wordText, {fontFamily: '"궁서", 궁서체, serif'}).setColor('#000000');
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)
{
......@@ -47,6 +60,11 @@ class WordObject
return this.wordWeight;
}
isEqualObject(_generationCode)
{
return _generationCode === this._generationCode;
}
//***********ToDo*************
isEqual(inputWord)
{
......
......@@ -2,6 +2,8 @@ var WordSpace = WordSpace || {};
WordSpace.isImageLoaded = false;
WordSpace.nextWordCode = 0;
WordSpace.wordGroup = [];
WordSpace.wordForcedGroup = [];
WordSpace.wordPhysicsGroup = null;
......
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