我有一系列硬币向下落下,当它下降时(y坐标<0)我将y更新为某个随机整数,这会导致纹理重叠。
GameState Class的内部构造函数
for (int i = 0; i < coins.length; i++) {
coins[i]= new Coin(i *(Coin.COIN_SPACING +Coin.COIN_WIDTH ),Game.HEIGHT/2 + i *(Coin.COIN_SPACING_VERTICAL +Coin.COIN_WIDTH));
}
内部覆盖更新方法
for (int i = 0; i < coins.length; i++) {
coins[i].update(dt,score/SCORE_DIVIDENT);
if(coins[i].collides(delta.getBounds())) {
//coins[i].getTexture().dispose();
score = score + 5;
mScore = "Score:"+score;
coins[i].playDropSound();
coins[i].setPosition(new Vector3(coins[i].getPosition().x, coins[i].getPosition().y+MConstant.GALAXY_GRAND_PRIME_HEIGHT *2,0));
coinCollided = true;
}
}
内部渲染覆盖方法
for (int i = 0; i < coins.length; i++) {
sb.draw(coins[i].getTexture(),coins[i].getPosition().x, coins[i].getPosition().y);
}