Home Game Development debugging – LibGDX: creating actor conformed by different actors

debugging – LibGDX: creating actor conformed by different actors

0
debugging – LibGDX: creating actor conformed by different actors

[ad_1]

I’m making my customized actor class, made up by 3 actors(oneProgressBar, one Label and one TextButton), as a result of I shall be utilizing this many instances, so it is not a good suggestion to create 3 of that actors after I can create one that may include them. So I’m making my class:

public class MyActor extends Actor {
ProgressBar bar;
Label titleLabel;
TextButton button;
public MyActor(String title, Skin pores and skin, float progress){
    titleLabel = new Label(title, pores and skin);
    button = new TextButton("Buy", pores and skin);
    bar = new ProgressBar(0f,5f,progress,false,pores and skin);
}


@Override
public void act(float delta) {
    tremendous.act(delta);
    bar.setBounds(getX(), getTop()-getHeight() / 3f, getWidth(), getHeight() / 3f);
    titleLabel.setBounds(getX(), getY()+getHeight() / 3f, getWidth(), getHeight() / 3f);
    button.setBounds(getX(), getY(), getWidth(), getHeight() / 3f);
}

@Override
public void draw(Batch batch, float parentAlpha) {
    tremendous.draw(batch, parentAlpha);
    bar.draw(batch, parentAlpha);
    titleLabel.draw(batch, parentAlpha);
    button.draw(batch,parentAlpha);
}


}

So in my recreation, I add my actor to the Stage utilizing a desk:

Table desk = new Table();
desk.debug();
MyActor actor = new MyActor("no matter",mySkin,1f);
desk.add(actor).measurement(myWidth,myHeight);

The actor is drawn within the right place(I do know due to the debug strains), however the 3 actor are drawn within the 0,0 coordinates, what am I doing unsuitable? do I have to override one other technique?

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here