
16
Collision detection
Collision detection
p = point(10, 20)
if inside(p, rect(20, 50, 30, 60) then
...
end if
if p.inside(rect(20, 50, 30, 60) then
...
end if
if sprite(n).intersects(sprite(m)) then
...
end if
if sprite(n).within(sprite(m)) then
...
end if
Rectangles are specified as (left, top, right, bottom).
If the sprites are drawn in matte ink, the intersects and within
methods use the outline of the sprites rather than the bounding boxes.
Keyboard interaction
Keyboard interaction
on keyUp me
if the key = ”a” then
...
end if
if the keycode = 123 then
put ”Cursor left”
end if
end
if keyPressed(
”a”) then
...
Catch the keyDown event to detect when keys are pressed (rather than released).
Key codes for the cursor keys are 123 (left), 124 (right), 125 (down), 126 (up).
Shift, Alt, etc. doesn’t generate events, but you can query their status inside
an event handler through the shiftDown, the commandDown,
the controlDown, and the optionDown.
Comentários a estes Manuais