-- -- Sprite follows a rectangle shape -- Ken Loge - http://diginoodles.com -- property pSpeed -- how fast the sprite moves property pRectSprite -- the sprite used to get the rectangle for movement property pRect -- the rectangle of points for the sprite movement property pState -- the current animation state of the sprite on beginSprite me pRect = sprite(pRectSprite).rect end on getPropertyDescriptionList me list = [:] addProp list, #pSpeed, [#comment: "Speed of movement:", #format: #integer, #default: 5] addProp list, #pRectSprite, [#comment: "Sprite channel of rectangle for movement:", #format: #integer, #default: 1] addProp list, #pState, [#comment: "Starting state for animation:", #format: #string, #default: "moveRight"] return list end on exitFrame me -- automatically switch from one animation state to the next case pState of "moveRight": moveItRight(me) "moveDown": moveItDown(me) "moveLeft": moveItLeft(me) "moveUp": moveItUp(me) end case end on moveItRight me sprite(me.spriteNum).locH = sprite(me.spriteNum).locH + pSpeed if sprite(me.spriteNum).locH > pRect[3] then pState = "moveDown" end if end on moveItDown me sprite(me.spriteNum).locV = sprite(me.spriteNum).locV + pSpeed if sprite(me.spriteNum).locV > pRect[4] then pState = "moveLeft" end if end on moveItLeft me sprite(me.spriteNum).locH = sprite(me.spriteNum).locH - pSpeed if sprite(me.spriteNum).locH < pRect[1] then pState = "moveUp" end if end on moveItUp me sprite(me.spriteNum).locV = sprite(me.spriteNum).locV - pSpeed if sprite(me.spriteNum).locV < pRect[2] then pState = "moveRight" end if end