I'm having trouble having aeCollision recognize a collision between to objects. In an attempt to use newer AE calls for moving objects, I seem to have hit a roadblock regarding initiating an aeCollision call.
Here's what I have:
Code: Select all
global newShot
on keyDown theKey
if theKey = space then
createshot
end if
end keyDown
on createShot
lock screen
lock messages
clone btn "bulletTemplate"
put the id of it into newShot
put the BulletList of current card into tBulletList
put newShot & cr after tBulletList
if line 1 of tBulletList is empty then delete line 1 of tBulletList
set the Bulletlist of this card to tBulletList
set the name of btn id newshot to "bullet"
getTargets
set the layer of btn id newshot to 1
set the loc of btn id newShot to the loc of grc "shooter"
put the long ID of btn id newShot into tLongID
put cd fld "theAngle" into tBulletAngle
get pointOnCircle(loc of last btn, tBulletAngle,1200)
put it into tTargetEnd
if there is a btn id newShot then
aeMoveto tLongID,tTargetEnd,1000
send aeStartListeningForCollisions to btn id newShot in 1 sec
send DeleteBullet to btn id newShot in 2 seconds
end if
end createShot
on DeleteBullet newShot
put the bulletList of current card into tBullets
put the ID of target into tTargetBullet
if there is a btn id tTargetBullet then
if the left of btn id tTargetBullet > the right of this card or the right of button id tTargetBullet < 0 or the bottom of button id tTargetBullet < 0 or the top of button id tTargetBullet > the bottom of this card then
aeStopListeningForCollisions
put the long id of btn id tTargetBullet into tLongIDofButton
delete line 1 of tBullets
delete button id tTargetBullet
end if
end if
set the bulletlist of current card to tBullets
end DeleteBullet
on CheckMe
repeat for each line theEnemy in the allEnemies of this cd
send movePolygonal to img ID theEnemy
end repeat
wait 0 with messages
unlock screen
if the flag of btn "startGame" then send checkme to me in 30 milliseconds
end CheckMe
command GetTargets
repeat with i = 2 to the number of images
put the long id of image i & cr after tList
end repeat
delete char -1 of tList
set the aeListenForCollisionsWith of button id newShot to tList
end GetTargets
on aeCollision pObjects
if the visible of pObjects is true then
put pObjects -- let me know the object was hit
pass aeCollision
else
pass aeCollision
end if
end aeCollision
Thank you!