babytarantula
Technical User
Hi do you know which code i should use in order to make a bird fly around the screen randomly and without leaving the screen
Thanks a lot!!!
Thanks a lot!!!
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
-- Behaviour script attached to a Sprite
property pSprite
property pSpeed
property pIdle
property pStageWidth, pStageHeight
property pCounter
property pLimit
property pVector
on beginSprite me
pSprite = sprite(me.spriteNum)
pSpeed = 3
pIdle = 30
stageRect = _movie.stage.rect
pStageWidth = stageRect[3]-stageRect[1]
pStageHeight = stageRect[4]-stageRect[2]
pCounter = 0
setNewVector()
end beginSprite
on enterFrame me
currentLoc = pSprite.loc
if currentLoc[1] < pSpeed then reverseVector(1)
if currentLoc[1] > (pStageWidth - pSpeed) then reverseVector(1)
if currentLoc[2] < pSpeed then reverseVector(2)
if currentLoc[2] > (pStageHeight - pSpeed) then reverseVector(2)
if pCounter > pLimit then setNewVector()
pSprite.loc = pSprite.loc + pVector
pCounter = pCounter + 1
end enterFrame
on reverseVector arg
pVector[arg] = -pVector[arg]
pSprite.loc = pSprite.loc + pVector
end reverseVector
on setNewVector
pCounter = 0
pLimit = random(pIdle)
pVector = point(random(3)-2, random(3)-2)*pSpeed
if pVector = point(0, 0) then
setNewVector()
else
return
end if
end setNewVector
--