Author Topic: Animating Sprites the right way  (Read 2942 times)

Landci

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 4
    • View Profile
Animating Sprites the right way
« on: May 13, 2014, 04:45:16 AM »
Hello, i would like to animate sprites with a simple fly in animation.
I want it to work on mobile and on every resolution.

I did find different kind of approches, using the animator, using sprite animation etc..
Using empty gamobject with animation on it and so on.

Well nothing worked out as i would like it to. Different resolution gives me different animation endposition.

So could you please tell me which is the right way to go for that when using NGUI 3.5.7

snlehton

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 1
  • Posts: 6
    • View Profile
Re: Animating Sprites the right way
« Reply #1 on: May 13, 2014, 08:58:27 AM »
What I've done is that I've used an extra positioning node which is the place where the UI element needs to be when the animation is done (let's call it Anchor). Under this I have the actual animating node (let's call this Offset) and under that I have the final sprite that you wanted to animate in the first place.

So the structure would look like this: Button_Anchor / Button_Offset / Button

In Button_Anchor you have a UIAnchor, and you position the sprite using it. Button_Offset has initially an offset of 0,0,0 (i.e. no offset at all), and then you add an animation to it (say UITween for example). Button has collider, the actual sprite and so forth, centered around origo.

After you've positioned the Button_Anchor in a correct place, you can use UITweenPosition in Button_Offset to tween the offset from, say, (0, -100, 0) to (0,0,0) if you want the button to come up from the bottom of the screen.

Why so many objects? Well, each of them has a specific purpose, and in order to keep things clean and as disconnected as possible, this is the way to do it.

Tip: you can use tween groups to create animations for entering and exiting the scene separately. So can make the button to fly out some other direction when exiting.