HI dyson,
I am trying to setup an enemy with a ‘radar’ which is a circle to detect
when my player comes into range so that the enemy will start firing.
I create my sprite for my player, and then I make a circle. I use
physics.newJoin to weld them together. So I have a ship with an invisible circle around it.
My problem is that when I touch scroll the map, I can start and stop the collisions, event though my player and the radar circle are out of range of each other. Is this the best way to do contact with the enemy?
This is my setup code: :
local setupradar = {kind = “sprite”, layer = mte.getSpriteLayer(1), locX
=params.itemx, locY =params.itemy, levelWidth = 256, levelHeight =256,}
local radar = display.newCircle(0,0,300)
radar.id = “radar”
mte.addSprite(radar, setupradar)
local setupenemy = {kind = “sprite”, layer = mte.getSpriteLayer(1), locX
=params.itemx, locY =params.itemy, levelWidth = 64, levelHeight =64,}
mte.addSprite(object, setupenemy)
physics.addBody( radar, “static”, { density = 1, friction = 0, bounce =
0, radius=300, isSensor = true} )
physics.newJoint( “weld”, object, radar, params.itemx, params.itemy )
Thanks, Greg