MoveTo Problem

Anything libgdx related goes here!

MoveTo Problem

Postby acr21 » Mon Jul 23, 2012 3:02 pm

I am trying to have a popup slide in from the bottom of the screen using MoveTo. It works great except for 1 problem. The popup flashes into place for a split second before animating in from off the bottom of the screen. I have tried everything I could think of to fix the issue but nothing seems to work. Please help. Thanks.

Code: Select all
public Popup(String titleText)
   {
      super(Game.GetSkin());
      super.setVisible(false);
      super.setTouchable(Touchable.enabled);
      
      solidPixel = new Texture(Gdx.files.internal("content/ui/solid_pixel.png"));
      
      Sprite backgroundSprite = new Sprite(solidPixel);
      backgroundSprite.setColor(0.0f, 0.0f, 0.0f, 0.8f);
      
      SpriteDrawable backgroundDrawable = new SpriteDrawable(backgroundSprite);
      
      Sprite popupBackgroundSprite = new Sprite(solidPixel);
      popupBackgroundSprite.setColor(1f, 1f, 1f, 1f);
      
      SpriteDrawable popupBackgroundDrawable = new SpriteDrawable(popupBackgroundSprite);
      
      Sprite titlebarBackgroundSprite = new Sprite(solidPixel);
      titlebarBackgroundSprite.setColor(0.0f, 138.0f / 255.0f, 1.0f, 1.0f);
      
      SpriteDrawable titlebarBackgroundDrawable = new SpriteDrawable(titlebarBackgroundSprite);
      
      super.setFillParent(true);
      super.setBackground(backgroundDrawable);
      super.bottom();
      
      popup = new Table(Game.GetSkin());
      popup.setBackground(popupBackgroundDrawable);
      
      super.add(popup).fillX().expandX();

      titlebar = new Table(Game.GetSkin());
      titlebar.setBackground(titlebarBackgroundDrawable);
      
      popup.add(titlebar).fillX().expandX();

      // Create title label
      Label titleLabel = new Label(titleText, Game.GetSkin());
      
      titlebar.add(titleLabel).fillX().expandX().left().pad(5);
      
      this.addListener(new ClickListener() {
         
         @Override
         public void clicked(InputEvent event, float x, float y) {
            event.cancel();
         }
      });
   }


Code: Select all
public void show()
   {
      this.getStage().setScrollFocus(this);
      super.pack();
      
      popup.addAction(Actions.moveTo(popup.getX(), popup.getY(), .5f));
      
      popup.setY(-popup.getHeight());

      super.setVisible(true);
   }
acr21
 
Posts: 115
Joined: Sun Sep 19, 2010 11:10 pm

Re: MoveTo Problem

Postby Semtiko » Mon Jul 23, 2012 4:20 pm

Hi! Do you try use "sequence" for this?

Code: Select all
popup.addAction(Actions.moveTo(popup.getX(), popup.getY(), .5f));
popup.setY(-popup.getHeight());

And maybe i was wrong, but "popup.getX(), popup.getY()" seems to leave the window in the original place?
Semtiko
 
Posts: 732
Joined: Tue Oct 18, 2011 9:03 am

Re: MoveTo Problem

Postby acr21 » Mon Jul 23, 2012 7:47 pm

Do I need to use sequence if its only one Action?
acr21
 
Posts: 115
Joined: Sun Sep 19, 2010 11:10 pm

Re: MoveTo Problem

Postby Semtiko » Mon Jul 23, 2012 8:29 pm

No, you can set completion listener for moveto, because "popup.setY" will be called earlier then first act ends.
Semtiko
 
Posts: 732
Joined: Tue Oct 18, 2011 9:03 am

Re: MoveTo Problem

Postby acr21 » Mon Jul 23, 2012 10:54 pm

I set where it's going to with this:
popup.addAction(Actions.moveTo(popup.getX(), popup.getY(), .5f));

but then I need to move it to its starting point with this:
popup.setY(-popup.getHeight());

Like I said...it works but it flashes in its final position first.
acr21
 
Posts: 115
Joined: Sun Sep 19, 2010 11:10 pm

Re: MoveTo Problem

Postby Varriount » Wed Jul 25, 2012 10:23 am

This is just a guess, but are you sure that you aren't rendering the panel first before ever adding or checking that it needs to be animated?
Think of the unanswered posters : search.php?search_id=unanswered
If I'm you and you're me, then who's he?
Varriount
 
Posts: 249
Joined: Tue Jun 05, 2012 2:48 pm

Re: MoveTo Problem

Postby luizfzs » Wed Jul 25, 2012 12:18 pm

No, you can set completion listener for moveto, because "popup.setY" will be called earlier then first act ends.


I was updating the api version of my project, but it seems the completion listener doesnt exist anymore.
luizfzs
 
Posts: 33
Joined: Tue Jul 03, 2012 1:12 pm

Re: MoveTo Problem

Postby Semtiko » Wed Jul 25, 2012 3:57 pm

luizfzs wrote:I was updating the api version of my project, but it seems the completion listener doesnt exist anymore.

I downloaded today nightly libs and have a "SequenceAction" in actions of stage2d. Try it.
Semtiko
 
Posts: 732
Joined: Tue Oct 18, 2011 9:03 am


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 11 guests