Tricks to getting a large animation sequence to play smoothly on an iPad 1

2»

Comments

  • CloudsClouds Member Posts: 1,599
    + scene.Background.uber 1.Position.X

    This means add in 'uber's' position to our own position (otherwise we would be doing the left to right oscillation thing down in the bottom left hand corner at 0,0) - and of course it also means that wherever 'uber' goes 'parent' will follow.


    -111

    This simply moves the actor 111 pixels left (uber is 222 wide and rather than 'parent' orbit around 'uber's' centre we want 'parent' to orbit around 'uber's' left hand end - so I shifted it 111 pixels to the left)

    (continued . . . . )
  • CloudsClouds Member Posts: 1,599
    That's basically it.

    The interesting thing is this: if we want our actor to travel in a circle why are we just oscillating it left to right (using the 'cos' function) ?

    Imagine this:

    We send our actor back and forth, going from left to right in a regular repeating pattern. So that's the X movement.
    Now we also send our actor going up and down in a regular repeating pattern. The Y movement.

    Ok, so something starts by going up and left . . . and then down and right . . .we end up with it travelling in a diagonal line.
    And as 'cos' just repeats it's oscillation forever we will have an actor travelling up and down this diagonal line for as long as the game runs.
  • CloudsClouds Member Posts: 1,599

    But, change where either X or Y starts in it's repeating pattern and the magic begins . . .
    Leave X going as it is (left to right to left to right to left . . . ) starting at it's centre point.
    But instead of Y going up > down > up > down . . . starting at it's centre point, start it from the bottom of it's oscillation.

    So now our start point for the actor is in the centre of the X (horizontal movement) and at the bottom of the Y (vertical movement).
    And we know where our oscillation is going . . . X is going left . . . Y is going up.
    So, our actor goes up and to the left - but as it reaches half way through going up - Y (vertical movement) - it has already reached the far left hand side of the X (horizontal movement) . . and as it continues up (Y) the X (horizontal movement) starts to move right and when the X (horizontal movement) hits half through it's X (horizontal movement) the Y has reached the top of it's Y (vertical movement) . . . . etc etc.
  • CloudsClouds Member Posts: 1,599

    We have a diamond !

    Ok, we don't want diamonds, we want a circle, so instead of simply going left to right and up and down we use 'cosine' which doesn't simply hit one end of it's range and start back the other way, it smoothly 'dampens' or 'eases' into the far ends of it's oscillation - so it slows down at the ends of it's travel then speeds up through it centre only to slow down again on the other side . . .and so on.

    And this turns our diamond into a (perfect) circle.
  • CloudsClouds Member Posts: 1,599
    edited January 2012
    Note: this is a non-mathimatical explanation of what is going on, I am sure a mathematician would explain it entirely differently (he would introduce the world of triangles to you!), but this serves as a mental image.

    One final note when shoving your actor along the Y path (up and down) - the quick and easy way to offset it's start point (so it starts at the bottom of it's range, rather than the centre) is to use 'sin' instead of 'cos' . . . . . 'sin' is just the same oscillation as cosine, but with it starts at -1 rather than 0.

    So sin is going -1 . . . . 0 . . . .+1 . . . .0 . . . . -1 . . . . 0 . . . .+1 . . . .0 . . . . -1 . . . . 0 . . . .+1 . . . .
    & cos is going 0 . . . .+1 . . . .0 . . . . -1 . . . . 0 . . . .+1 . . . .0 . . . . -1 . . . . 0 . . . .+1 . . . 0 . . . . .

    (Actually I can't remember which way around it is, but one (cos or sin) is offset from the other !)

    I hope some of that makes sense ! It's one of those things that are pretty simple but look complicated when explained.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Hey T, Thanks a lot for this, sorry I haven't been responding - been busy. I will see what I can do. Should be posting a trailer tonight/tomorrow.
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Tynan, I've PM'd you, check your Messages.
  • CloudsClouds Member Posts: 1,599
    @TouchTiltGames

    I've just sent you an email.
Sign In or Register to comment.