Word Collider Animate方法

时间:2016-11-13 15:17:00

标签: java

我目前正在研究一个单词对撞机程序。这个程序的目的是有两个单词,一旦两个单词相互重叠,单词就会爆炸,字母将散布在整个地方。以下是变量名称的名称

private Text word1;
private Text word2;
// the characters contained in word1
private Text[] charWord1;
// the characters contained in word2
private Text[] charWord2;

我特别关注Animate方法的问题。以下是代码

/**
 * Randomize the position of the two words repeatedly and stop
 * when the bounding box of the two words overlaps.
 */
public void animate()
{
    while(checkOverlap() == false){
        word1.randomizePosition();
        word2.randomizePosition();
    }

    while(checkOverlap() == true){ 
        word1.makeInvisible();
        word2.makeInvisible();
    }

    for(int i = 0; i < charWord1.length; i++){
        word1.makeVisible();
        word1.randomizePosition();
    }

    for(int i = 0; i < charWord2.length; i++){
        word2.makeVisible();
        word2.randomizePosition();
    }
}

当检查重叠变为真时,我希望单词爆炸,每个单词的字母分散在屏幕上。我不太确定如何解决这个问题。

0 个答案:

没有答案