Found a problem during the game, objects are generated and fall from behind the screen. These objects can be of different types. Some have animation. The first few pieces that have animation, render it normally. But after some period of time, one new object has several layers with animation. Several times I checked that only one object is created, so I discarded the option with the fact that the overlapping of objects occurs. Please tell me where I was wrong.
Here is the method where I get the texture to the object
public void createTexture() { if (!(Prefers.getInstance().settings.getInteger(BoltType.DICK) == 0)) { sprite = new Sprite(ResourceManager.getResourceManager().getTexture("bolt")); sprite.setBounds(body.getPosition().x - BOLT_RADIUS * 3, body.getPosition().y - BOLT_RADIUS * 2, BOLT_RADIUS * 3, BOLT_RADIUS * 2); sprite.setOriginCenter(); } else { anim = new Animations(ResourceManager.getResourceManager().getRegions("bolt"), true, 0.06f); anim.setPosition(body.getPosition().x - BOLT_RADIUS * 2, body.getPosition().y - BOLT_RADIUS * 2); anim.setSize(BOLT_RADIUS * 4, BOLT_RADIUS * 3); anim.setRotation(body.getAngle() * MathUtils.radiansToDegrees); anim.setOriginCenter(); } } Below - actor drawing
setPosition(body.getPosition().x, body.getPosition().y * MobilesScreen.RATIO_PPM); if (sprite != null) { sprite.setPosition(body.getPosition().x - BOLT_RADIUS, body.getPosition().y - BOLT_RADIUS); sprite.setRotation(MathUtils.radiansToDegrees * body.getAngle()); } if (dick != null) { dick.setPosition(body.getPosition().x - BOLT_RADIUS * 2, body.getPosition().y - BOLT_RADIUS * 2); dick.setRotation(body.getAngle() * MathUtils.radiansToDegrees); } Texture rendering
@Override public void draw(Batch batch, float parentAlpha) { if (dick != null) { dick.animRender(batch); } if (sprite != null) { sprite.draw(batch); } } What am I doing wrong?