movePolygonalReversePath

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

Moderators: heatherlaine, kevinmiller, robinmiller, malte

Post Reply
niconiko
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 32
Joined: Mon Jul 17, 2006 2:28 am
Location: Motegi, Japan

movePolygonalReversePath

Post by niconiko » Wed Jul 19, 2006 10:55 pm

From AE docs, I cannot figure how to make an image
move backwards on a graphic-based path.

Below is the outline of my script, which does not work.

Thank you.

-- Nicolas Cueto

on mouseUp
set the movePolygonal["pointlist"] of image "someImage" to the points of graphic "someGraphic"
hereWeGo
end mouseUp

on hereWeGo
send movePolygonalReversePath to image "someImage"
send hereWeGo to me in 20 milliseconds
end hereWeGo

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

Post by malte » Thu Jul 20, 2006 6:25 am

Hi Nicolas,

movePolygonalRevertPath only needs to be called once. The pointlist is inverted then. What your script does is changing the path of the image every 20 milliseconds, but the image does not receive the instruction to actually move the image.

So to move your image backwards try something like this:

Code: Select all

on mouseUp
set the movePolygonal["pointlist"] of image "someImage" to the points of graphic "someGraphic"
send movePolygonalReversePath to image "someImage"
hereWeGo
end mouseUp

on hereWeGo
send movePolygonal to image "someImage"
send hereWeGo to me in 20 milliseconds
end hereWeGo
If you want to revert the path again you can now

send movePolygonalRevertPath to the image anytime. (try it from another button or the messagebox)

e.G.

Code: Select all

on mouseUp
  send movePolygonalRevertPath to image "someImage"
end mouseUp
Also, unless the path of the image changes every time you hit the first button, you might want to store the pointlist only once, not everytime the button is clicked. This will save a few CPU cycles. ;-)

Hope that helps,

Malte

niconiko
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 32
Joined: Mon Jul 17, 2006 2:28 am
Location: Motegi, Japan

movePolygonalReversePath

Post by niconiko » Fri Jul 21, 2006 3:10 am

Thank you, Malte.

Now that my image is moving backwards,
I'd also welcome advice on two more effects
I'd like to add to this backward motion. Plus,
I have some questions about the properties
of the movePolygonal custom property stored
in the moving image object.


First. When my backwards-moving image
gets to the end of the path, how do I get it
to return to the beginning of that same path?

To do this, I tried "set the movePolygonal ...
to the points of graphic someGraphic", but
this resets the moving object to the path's
beginning only if "someGraphic" is different
each time "set the movePolygonal" is called.


Second. How can I make the moving image
temporarily stop and then resume moving
from the point that it was stopped at?

With forward motion, this stop-start effect
works automatically. But not with backward
motion.


Finally, fiddling with the various AE properties
related to movePolygonal has raised some
questions not answered sufficiently for me
by the docs.

Specifically, what does the "current" property
refer to?

Looking at my moving objects custom properties,
it seems that "current" is the line number of the
pointlist coordinates, and which represents the
location of the moving object at each moment.

If so, how does movePolygonalReversePath relate
to how "current" counts up... or down?

Confused but curious!

-- Nicolas Cueto

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

Post by malte » Fri Jul 21, 2006 12:21 pm

Hi Nicolas,

normally it should not matter if your image moves "backwards" or "forwards". It is the same for AE. Could you send me the problematic stack offlist, that I can take a look at it?

The image should "loop" on that that path, so if it reaches the end it will start at the beginning automatically when the next movePolygonal message is sent to it. If you want to reset the moving object to the beginning of the path by script you would need to do the following:

set the movePolygonal["isDistance"] of img "someImage" to 0
set the movePolygonal["current"] of img "someImage" to 2

Maybe I should add a reset handler for all moving messages???

For the custom properties:

Yes, I think the docs need to be clearer here. :-)

movePolygonal works the following way: It splits the polygon into lineSegements, defined by the points stored in the movePolygonal["pointList"]. The object is moved along those linesegements. movePolyGonal["current"] is an index of the current endPoint of the linesegment in that list. So it starts with 2 and is increased when movePolygonal uses the next linesegment to move on. MovePolygonal["current"] has a value between 2 and the number of lines of the movePolygonal["pointlist"] of the moving object.

Thanks for your input on this. It is very valuable for me, as I see where I need to improve the docs.

All the best,

Malte
[/img]

Post Reply

Return to “Animation Engine”