Timing Moves

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

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Timing Moves

Post by doobox » Fri May 24, 2013 3:47 pm

Hi there,

Can someone please explain to me why the time stamps in this code are all identical, regardless if i use aeLockMoves or not, i would expect them to increment by the time each move takes.

on openKeyboard
if not(sKeyboardIsOpen) then
put true into sKeyboardIsOpen
put the loc of img "keyboardCloseButton" into tOrgonalKeyboardButtonLoc
// keyboard entire group
put item 1 of the loc of group "keyboard" into tKeyboardOpenX
put item 2 of the loc of group "keyboard" - (the height of this card / 2) into tKeyboardOpenY
aeLockMoves
put the seconds into field "test" // >>>>>> TIME
aeMoveTo the long ID of group "keyboard",tKeyboardOpenX,tKeyboardOpenY,200,"out"
put the top of group "keyboardKeys" - the bottom of this card + the height of group "keyboardKeys" into tRowMoveDistance
// keys row 1
put item 2 of the loc of group "keyboardRow1" - tRowMoveDistance into tKeyboardOpenY
put cr & the seconds after field "test" // >>>>>> TIME
aeMoveTo the long ID of group "keyboardRow1",tKeyboardOpenX,tKeyboardOpenY,350,"out"
// keys row 2
put item 2 of the loc of group "keyboardRow2" - tRowMoveDistance into tKeyboardOpenY
put cr & the seconds after field "test" // >>>>>> TIME
aeMoveTo the long ID of group "keyboardRow2",tKeyboardOpenX,tKeyboardOpenY,400,"out"
// keys row 3
put item 2 of the loc of group "keyboardRow3" - tRowMoveDistance into tKeyboardOpenY
put cr & the seconds after field "test" // >>>>>> TIME
aeMoveTo the long ID of group "keyboardRow3",tKeyboardOpenX,tKeyboardOpenY,450,"out"
// keys row 4
put item 2 of the loc of group "keyboardRow4" - tRowMoveDistance into tKeyboardOpenY
put cr & the seconds after field "test" // >>>>>> TIME
aeMoveTo the long ID of group "keyboardRow4",tKeyboardOpenX,tKeyboardOpenY,500,"out"
aeUnlockMoves
// close button
put the top of group "keyboardKeys" - the top of group "keyboard" into tWhiteHeight
put tWhiteHeight / 2 into tButtonOffeset
put item 2 of the loc of img "keyboardCloseButton" - round(the height of this card /2) into tButtonSlideDistance
put item 2 of the loc of img "keyboardCloseButton" - tButtonSlideDistance + tButtonOffeset into tNewButtonLocY
put cr & the seconds after field "test" // >>>>>> TIME
aeMoveTo the long ID of image "keyboardCloseButton",tKeyboardOpenX,tNewButtonLocY,600,"out"
end if
end openKeyboard
Kind Regards
Gary

https://www.doobox.co.uk

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Timing Moves

Post by malte » Fri May 24, 2013 6:06 pm

Hi Gary,

not completely sure what you are trying to do here.

aeMoveTo is non blocking. So it does not wait until the moving is done. Instead you are passing the time the move should take as a parameter to the command (in milliseconds, not seconds). However, aeMoveTo will send a callback to the moving object once it completes the move (aeMoveDone is sent to the target object).

aeLockMoves can be used to start all new move commands at the same time, to keep the start of multiple objects in sync.

Hope this clears things up a bit. If not, please try to describe what you want to achieve in a little more detil. Maybe then I can help.

All the best,

Malte

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Timing Moves

Post by doobox » Fri May 24, 2013 8:30 pm

I Just stuck the time stamps in there to see what was going on.

What a want is to execute all but the last move in that code, and execute the last one when the others complete.
So i guess i need to move the last object from an aeMoveDone handler in the object relating to the second last move in my code right..?
Kind Regards
Gary

https://www.doobox.co.uk

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Timing Moves

Post by malte » Sat May 25, 2013 11:28 am

That would be one option, yes. What you also could do is send your last move in time:

Code: Select all


-- someWhere in your original code:
send "timedMove" to me in 1 second

on timedMove
  aeMoveTo the long ID of image "keyboardCloseButton",tKeyboardOpenX,tNewButtonLocY,600,"out"
end timedMove
Hope that helps,

Malte

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Timing Moves

Post by doobox » Sat May 25, 2013 11:40 am

Yes i think that would be more manageable, as that same second last object is also moved in another handler "on keyboardClose"
That would save me having an if condition in the second last objects aeMoveDone handler. And i may eventually expand the code and this would lead to headaches.
Thanks a million :-)
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Timing Moves

Post by doobox » Sat May 25, 2013 11:49 am

Begs the question : Would it be possible in a future update to have the option to provide a parameter to the calls like :

aeMoveTo the long ID of grc "movingGrc",the loc of this card,1000,"inOut","blocking"
aeMoveTo the long ID of grc "movingGrc",the loc of this card,1000,"inOut","nonBlocking"

or


aeMovesBlock true


This would avoid the need for convoluted calls when a procedural approach is called for.
Kind Regards
Gary

https://www.doobox.co.uk

malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Location: Ostenfeld germany
Contact:

Re: Timing Moves

Post by malte » Mon May 27, 2013 2:44 pm

Hi Gary,

I guess this would be rather difficult. Actually I have no idea how I would tackle this in the best manner.

An option would be to place a wait with messages, but that appears wrong on quite a few levels to me. :-) I could try to experiment with that and make it an option, however, no promise made here that this will be in ae anytime soon.

All the best,

Malte

Post Reply

Return to “Animation Engine”