Page 1 of 1

Newbie question. Simultaneous action and facing?

Posted: Wed May 19, 2010 1:07 am
by DaveyJJ
Two quick questions.

Code: Select all

on arrowKey theKey
   // move player image
   if theKey is "up" then move image "player" relative 0,-50 in 0.5 seconds
   if theKey is "down" then move image "player" relative 0,50 in 0.5 seconds
   if theKey is "left" then move image "player" relative -50,0 in 0.5 seconds
   if theKey is "right" then move image "player" relative 50,0 in 0.5 seconds
   // move ground slower in a parallax type movement
   if theKey is "up" then move image "ground" relative 0,10 in 0.5 seconds
   if theKey is "down" then move image "ground" relative 0,-10 in 0.5 seconds
end arrowKey
How do I get the player movement, on the up and down keys, for example, and the associated ground movement to work simultaneously? Sort of like ...

Code: Select all

on arrowKey theKey
   // move player image
   if theKey is "up" then move image "player" relative 0,-50 AND move image "ground" relative 0,10 in 0.5 seconds  in 0.5 seconds
   if theKey is "down" then move image "player" relative 0,50 AND AND move image "ground" relative 0,-10 in 0.5 seconds in 0.5 seconds
   if theKey is "left" then move image "player" relative -50,0 in 0.5 seconds
   if theKey is "right" then move image "player" relative 50,0 in 0.5 seconds
end arrowKey
doesn't work. Am I missing brackets to isolate each instruction before the "in 0.5 seconds" or something?

Second question. How do I make a button or image rotate at a variable speed (rotateSpeed) to always point at (track/watch) another image?

Thank you.

Re: Newbie question. Simultaneous action and facing?

Posted: Wed May 19, 2010 10:29 am
by bn
Dave,
try this

Code: Select all

on arrowKey theKey
   if theKey is up then
      set the lockMoves to true
      move image 1 relative 0,-50 in 0.5 seconds without waiting
      move button 1 relative 0,-50 in 0.5 seconds  without waiting
      set the lockMoves to false
   end if
   if theKey is down then
      set the lockMoves to true
      move image 1 relative 0,50 in 0.5 seconds without waiting
      move button 1 relative 0,50 in 0.5 seconds without waiting
      set the lockMoves to false
   end if
end arrowKey
etc.
look up "lockMoves" and "move without waiting" in the dictionary
DaveyJJ wrote:Second question. How do I make a button or image rotate at a variable speed (rotateSpeed) to always point at (track/watch) another image?
this is a bit difficult since you can not rotate images in Rev very well, 90 degree steps are ok but if you rotate them repeatedly in smaller increcments they become distorted. What I have seen is that people make multiple images that "look" into the directions you want and then show/hide them accordingly. You would still have to calculate the angle between the two objects.
But maybe someone more into games might have a better idea.
regards
Bernd