how to properly sequence 2 aemoveto's

Create fast, sprite powered games with Animation Engine, co-developed with DerBrill Software!

Moderators: heatherlaine, kevinmiller, robinmiller, malte

how to properly sequence 2 aemoveto's

Postby adventuresofgreg » Tue Jun 12, 2012 10:19 pm

Hi: I am moving a group using aemoveto for 100 milliseconds, then I want to move it somewhere else. I've been using "wait for 500 milliseconds with messages" after the first aemoveto, to allow that first move to finish before starrting the next aemoveto.

I understand that wait with messages is a problem in iOS deployment - is there a better way to control the sequence of moves?

thanks
Greg
adventuresofgreg
 
Posts: 286
Joined: Tue Oct 28, 2008 1:23 am

Re: how to properly sequence 2 aemoveto's

Postby malte » Wed Jun 13, 2012 7:48 am

HI Greag,

you can either make use of the callbackMessage aeMoveTo sends, or use send in time to achieve what you want.


Code: Select all
in a button:

on mouseUp
  set the flag of me to not the flag of me
  if the flag of me then
    moveRandom
  end if
end mouseUp


in the card script:

on moveRandom
      aeMoveTo the long id of btn "myButton", random(the width of this stack),random(the height of this stack),500,"bounce"
end moveRandom

on aeMoveDone
  if the short name of the target="myButton" then
    if the flag of btn "myButton" then
      send "moveRandom" to me in 3 seconds
    end if
  end if
end aeMoveDone


Hope that helps. Malte
malte
 
Posts: 1096
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany

Re: how to properly sequence 2 aemoveto's

Postby adventuresofgreg » Wed Jun 13, 2012 4:23 pm

Hi Malte:

Thanks for that - yes, I have played with the aeMoveDone callback message a bit and I'm not really understanding how this can be used in a very large, complex script with many different moving items that are each coordinated in time. For example:

aemoveto thisthing for 5 seconds
wait 5 seconds
aemoveto thisthing for 1 second
wait 1 second
aemoveto differentThing for 4 seconds
aemoveto anotherThing for 4 seconds
wait 4 seconds
aemoveto thisThing for 2 seconds
aemoveto differentThing for 3 seconds
wait 3 seconds

If I was to use the aeMoveDone rather than using "wait", I would require a separate handler for each occurance of a aemoveto in the above script - it could get very confusing and complicated. yes? or am I not really understanding how to apply the callback?

Cheers,
Greg
adventuresofgreg
 
Posts: 286
Joined: Tue Oct 28, 2008 1:23 am

Re: how to properly sequence 2 aemoveto's

Postby malte » Thu Jun 14, 2012 6:42 am

Hi Greg,

you can either give each control its on aeMoveDone handler, this can get confusing, or instead move the callback to card level and chack the name of the target (aeMoveDone is sent to the control that stops moving), or use a completely different strategy.

on moveIt pTarget,pX,pY,pTime,pEffect
aeMoveto pTarget,pX,pY,pTime,pEffect
end moveIt

and then change your original pseudo code to

aemoveto thisthing for 5 seconds
send "moveIt" && the long ID of thisTHing&","&x&","&y&","&1000 to this cd in 5 seconds
...

hth,

Malte
malte
 
Posts: 1096
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany

Re: how to properly sequence 2 aemoveto's

Postby adventuresofgreg » Thu Jun 14, 2012 5:30 pm

Thank you Malte. I have been playing with the callbacks and I'm slowly getting the hang of it.
adventuresofgreg
 
Posts: 286
Joined: Tue Oct 28, 2008 1:23 am


Return to Animation Engine

Who is online

Users browsing this forum: No registered users and 2 guests