Page 1 of 1

Moving an image on a card

Posted: Mon Mar 10, 2008 4:54 pm
by Andycal
Is it possible to have an image or graphic on a card that the user can click on and move along a set path?

Posted: Mon Mar 10, 2008 9:24 pm
by Mark
Hi Any,

There are several ways to do this. The easiest way is to use the move command, e.g.

Code: Select all

move img 1 from 10,10 to 200,200 in 5 secs with messages
This moves the image over a straight line. A neat trick is

Code: Select all

move img 1 to the points of graphic "Polygon" in 10 seconds 
which makes the image follow a path as defined by the points of a (hidden?) polygon. You need to draw the polygon first and you should make one with very many points.

You might also create a mathematical function to calculate the points and store these points in a return delimited list. Then use this list instead of the points of a polygon graphic.

Best,

Mark

Posted: Mon Mar 10, 2008 9:36 pm
by Andycal
Can this command be used so they can actually drag the graphic along?

Posted: Mon Mar 10, 2008 10:36 pm
by Andycal
Right, just read some more docs and I realise I'm being a bit cryptic.

I've just noticed that this almost does what I want:

Code: Select all

on mouseDown pMouseBtnNum
    grab me
    
end mouseDown
    
However, I only want to move the graphic horizontally between points 10 and 150 (for example).

Posted: Mon Mar 10, 2008 11:14 pm
by Mark
Hi Andy,

That's simple:

Code: Select all

on mouseDown
  put item 2 of the loc of me into myY
  repeat until the mouse is up with messages
    put the mouseH into myX
    if myX > 9 and myX < 151 then
      set the loc of me to the myX,myY
    end if
    wait 0 millisecs with messages
  end repeat
end mouseDown
Best,

Mark

Posted: Wed Mar 12, 2008 6:19 pm
by Andycal
Thanks for this Mark, I think I've got it now, just experimenting...