Monday, May 12, 2025
spot_img

Learn how to rotate a picture on contact utilizing RotateToAction in libGDX?


enter image description here

I wish to rotate my picture on contact however it by no means applies motion, I am utilizing RotateToAction to attain this.

class actorCark extends Actor
{
    Texture texture;
    Sprite sprite;
    International g;
    GetActorByName a;
    public actorCark()
    {
        ses=new sesler();
        g=new International();
        a=new GetActorByName();
        sr=new soruSor();
        texture=new Texture(Gdx.information.inside("pictures/carkifelek.png"));
        sprite=new Sprite(texture);
        setBounds(International.screen_width / 2 - International.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight() / 2, International.screen_height / 2 - International.screen_height * 0.9F / 2, International.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight(), International.screen_height * 0.9F);
        setTouchable(Touchable.enabled);
        addListener(new InputListener() {
            public boolean touchDown(InputEvent occasion, float x, float y, int pointer, int buttons) {
                clearActions();
                RotateToAction rotateToAction=new RotateToAction();
                rotateToAction.setRotation(360);
                rotateToAction.setDuration(2);
                addAction(rotateToAction);
                dondur();
                sesler.donmeS.play();
                return true;
            }
        });
    }
    @Override
    public void act(float delta) {
        tremendous.act(delta);
    }
    public void draw(Batch batch, float alpha)
    {
        sprite.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear);
        sprite.setBounds(International.screen_width / 2 - International.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight() / 2, International.screen_height / 2 - International.screen_height * 0.9F / 2, International.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight(), International.screen_height * 0.9F);
        sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
        sprite.draw(batch);
    }
}

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisement -spot_img

Latest Articles