Hi,
I am trying to make space fighting game
So i made player space ship and i made enemy ships and player ship can throw laser... I have two main function. startPlane() is create the player ship and add events when player touch the screen, ship throw laser. startEnemies() is create the enemies and start to enemy movement.
When player touch the screen, event start the fire() function. And fire function create the fire object and start the moveFire function. moveFire function is add -y for move the fire. Now, how can i detect when laser hit the enemy ?
Comments
I'd say to look for TNTcollision Engine to check points/shapes collisions without physics (it's a "plugin" for gideros).
If you like to engage with physics/gravity and forces you can try box2d (already available in gideros).
i didnt make this. It's @WauloK 's
http://bluebilby.com/2013/05/08/gideros-mobile-tutorial-creating-your-first-game/
check out :hitTestPoint
_________________________________________________________________________________
local function goTouch(gameOverImage, event)
-- See if the Game Over object was touched
if gameOverImage:hitTestPoint(event.touch.x, event.touch.y) then
gameoverImg:removeEventListener(Event.TOUCHES_END, goTouch)
-- Clean up our objects
stage:removeChild(gameoverImg)
gameoverImg=nil
local i
for i = 1,MAXNUMBEROFENEMIES do
stage:removeChild(enemyShape[i])
enemyShape[i]=nil
end
stage:removeChild(player)
player=nil
stage:removeChild(hiScoreText)
hiScoreText=nil
stage:removeChild(scoreText)
scoreText=nil
-- Restart the game
startGame()
end
end
2) @Harrison mentioned hitTestPoint
3) Using box2d physics engine
3) using bounding box check: