Author Topic: question regarding UIStretch'ed sprites animating in from left edge of screen  (Read 8005 times)

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
I have three sprites that animate in from the left edge of the screen.  They are UIStretched to fill the screen horizontally. (think active achievements or something).  The animation simply animates their transform positions to move them left to right in succession.  The problem is this works on the aspect ratio I originally animated the objects on (iphone5), but fails on the ipad which has a different aspect ratio.

What is the proper way to do this so that it works for all aspect ratios?  I have text and icons anchored to these sprites... those should be easy to fix once I can get the animation to work for different devices.

Thanks!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
If the animation is playing, the stretching and anchoring gets disabled. You need to animate the parent object, not the stretched object.

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
Yes, I'm animating the parent(s).

top panel object <animation object here>
    group0 <empty game object that has it's transform position animated, no UIStretch or UIAnchor>
        child0
        child1
        child2
    group1 <same as above>
    ...
    groupx

The animation only translates the group0...groupX objects based on the screen width for iphone5.. so when you play it on an iPad, they don't animate all the way off screen.  I need to know what's the best way to get this to work.  I could write a little script for each group_ object, expose a value that can be animated from 0 -> 1 and then position them according to screen width?  or is there an easier way?

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
So when you say it "fails" -- what do you mean exactly? Keep in mind different aspect ratios mean the amount you need to move by will vary as well. 1136 vs 1024 for example.

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
It fails in that with a wider screened device, the sprite backgrounds are left on screen because the animation didn't move them all the way off the screen.  Basing the animation on the largest screen size available right now isn't really the best solution I think.

thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Yes it is. Animations are finite -- you specify a target and it animates to it. You can't make it animate to some fluidly set value unless you use a TweenTransform towards an anchored object.

andrew

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 44
    • View Profile
I'll look at the TweenTransform.. thanks