Home Game Development How to rotate a picture on contact utilizing RotateToAction in libGDX?

How to rotate a picture on contact utilizing RotateToAction in libGDX?

0
How to rotate a picture on contact utilizing RotateToAction in libGDX?

[ad_1]

enter image description here

I need to rotate my picture on contact nevertheless it by no means applies motion, I’m utilizing RotateToAction to attain this.

class actorCark extends Actor
{
    Texture texture;
    Sprite sprite;
    Global g;
    GetActorByName a;
    public actorCark()
    {
        ses=new sesler();
        g=new Global();
        a=new GetActorByName();
        sr=new soruSor();
        texture=new Texture(Gdx.recordsdata.inner("pictures/carkifelek.png"));
        sprite=new Sprite(texture);
        setBounds(Global.screen_width / 2 - Global.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight() / 2, Global.screen_height / 2 - Global.screen_height * 0.9F / 2, Global.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight(), Global.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(Global.screen_width / 2 - Global.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight() / 2, Global.screen_height / 2 - Global.screen_height * 0.9F / 2, Global.screen_height * 0.9F * sprite.getTexture().getWidth() / sprite.getTexture().getHeight(), Global.screen_height * 0.9F);
        sprite.setOrigin(sprite.getWidth() / 2, sprite.getHeight() / 2);
        sprite.draw(batch);
    }
}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here