简体   繁体   中英

How to active scene2d simple moveTo on it?? libgdx

How to active scene2d simple move on it?? libgdx

My code like this, but I want to apply scene2d simple moveto code on it

public Mario(World world, PlayScreen screen){
    super(screen.getAtlas().findRegion("little_mario"));

    this.world = world;
    defineMario();
    marioStand = new TextureRegion(getTexture(),0,11,16,16);
    setBounds(0,0,16/ MarioBros.PPM, 16 / MarioBros.PPM);
    setRegion(marioStand);

}

Doing simple moveto feature

public Mario(World world, PlayScreen screen){
    super(screen.getAtlas().findRegion("little_mario"));

    this.world = world;
    defineMario();
    marioStand = new TextureRegion(getTexture(),0,11,16,16);
    setBounds(0,0,16/ MarioBros.PPM, 16 / MarioBros.PPM);
    setRegion(marioStand);

    stage = new Stage(); 
    stage.addActor(this);//Error

    this.addAction(Actions.sequence(Actions.moveTo(500,500,0.5f)));//Not Work

}

Anyidea to make Moveto scene2D function????

You are defining a Stage that is nowhere. For this Stage to work, you must tie it to a Screen and call act() and draw().

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM