java - LibGDX - Does modifying a Group affects children? -


i wonder if there way affect actors children when parent group modified ? attached him. modifying mean doing conventional actions translation, rotation, scale ...

i know possible parent alpha affect children's alpha via draw() method, other attributes ?

for example if add translationaction group want affect children.

so did miss in scene2d api or have code own (not hard, want avoid if possible) ?

if it's not possible actual api purpose of using group ?

the answer question yes , no. because scene2d api designed around using spritebatch sets sorts of transformation information between parent , children actors.

if using spritebatch (i.e. drawing textures, , such it) yes actions applied parent affect children. there couple of exceptions actors if remember correctly think has things color, etc.

if not using spritebatch (i.e. drawing geometry directly opengl, or custom drawing actions (such meshes) outside of offered scene2d api) no actions not affect children. have write own code either subclassing scene2d or creating simple yourself. know isn't best thing ever 'libgdx tries not "end all, all" solution'.

the 'magic' how transforms work located in group (link source). group class uses method called drawchildren() iterate on children , draws them based on transformed spritebatch. transformation occurs in draw() method of group class.

this isn't real answer without example code, assume know how setup skins. end result of program below group button @ 50,100 , hello button @ 100,50. notice didn't make direct changes group button, put inside group , translated whole group instead.

public class groups implements applicationlistener {     private stage stage;     private skin uiskin;      @override public void create() {         this.stage = new stage(gdx.graphics.getwidth(), gdx.graphics.getheight(), false);         gdx.input.setinputprocessor(this.stage);          this.uiskin = new skin(gdx.files.internal("skin/uiskin.json"));          final textbutton plaintextbutton = new textbutton("hello", this.uiskin);         this.stage.addactor(plaintextbutton);          final group group = new group();         final textbutton grouptextbutton = new textbutton("group", this.uiskin);         group.addactor(grouptextbutton);         this.stage.addactor(group);          plaintextbutton.addaction(actions.moveby(100, 50));         group.addaction(actions.moveby(50, 100));          gdx.gl20.glclearcolor(0f, 0f, 0f, 1);         gdx.gl20.glblendfunc(gl20.gl_src_alpha, gl20.gl_one_minus_src_alpha);     }      @override public void render() {         this.stage.act();         gdx.gl20.glclear(gl20.gl_color_buffer_bit);         this.stage.draw();     }      @override public void dispose() {}     @override public void resize(final int width, final int height) {}     @override public void pause() {}     @override public void resume() {} } 

hopefully gives enough information , bit of explanation scene2d.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -