Moving the box code

Cut and paste the following code into your "card Script". I called my card "myCard" and the button "box" If you named your button and card something different, then change it in the code below:


on arrowkey x

if x is "up" then
  set the top of button "box" to the top of button "box" - 10
  if top of button "box" < 0 then
    set the top of button "box" to 0
  end if
end if

if x is "down" then
  set the bottom of button "box" to the bottom of button "box" + 10
  if the bottom of button "box" > the bottom of card "mycard" then
    set the bottom of button "box" to the bottom of card "mycard"
  end if
end if

if x is "left" then
  set the left of button "box" to the left of button "box" - 10
  if the left of button "box" < 0 then
    set the left of button "box" to 0
  end if
end if

if x is "right" then
  set the right of button "box" to the right of button "box" + 10
  if right of button "box" > the right of card "mycard" then
    set the right of button "box" to the right of card "mycard"
  end if
end if

end arrowKey

Comments