Ich denke, das Laden vieler Texturen in meiner Animation verursachen die leichte Verzögerung in meinem Spiel, und ich möchte meine Array-Texturen in einem TextureAtlas. Der folgende Code ist mein Animationscode und er wird auch den Textur-Frame-Index in der Animation erhalten und eine Aufgabe ausführen, wenn der Textur-Index angezeigt wird ...., ich habe bereits eine .pack-Datei namens shot.pack für texture atlas, aber ich wusste nicht, wie man es anwendet und es so macht. Ich hoffe, dass jemand helfen kannTexturen Textur Atlas und Animation
Texture[] shot;
//At CONSTRUCTOR
shot = new Texture[21];
for(int i=0; i <21; i++){
if(i == 19 || i==20){
shot[i]=new Texture("s18.png");
}
else {
shot[i] = new Texture("s" + Integer.toString(i) + ".png");
}
}
//animation
animation = new Animation(1/19f,shot);
//@render METHOD
sb.draw((Texture) animation.getKeyFrame(timePassed, false), ShootingTreys.WIDTH * 0.03f, ShootingTreys.HEIGHT * 0.03f, (ShootingTreys.WIDTH * 1/6), (ShootingTreys.HEIGHT/2) + (ShootingTreys.HEIGHT * 0.13f));
if (animation.getKeyFrameIndex(timePassed) == 20) {
isShotDelay = true;
shotDelay += Gdx.graphics.getDeltaTime();
if (shotDelay >= 0.2f || ball.getBall().getY() < ShootingTreys.HEIGHT * 0.2f) {
touch = false;
timePassed = 0;
shotDelay = 0;
isShotDelay = true;
//for missed ball
colide = false;
}
}
Wie kann ich ein einzelnes Bild anzeigen, wenn die Animation fertig ist? –
Meine Textur in Textur Packer war nicht in Ordnung –
setzen Sie eine Bedingung in Rendering für Animation und zeigen Einzelbild über diese Bedingung. – Aryan