Kinematic objects do not generate collision events. You could make it “dynamic” and set .isSensor to true and that will generate collisions. If you don’t want gravity affecting your entire game, you can turn it off for the whole world, or if you want gravity off for a specific object then you can set the object’s gravityScale to 0. See: https://docs.coronalabs.com/api/type/Body/gravityScale.html
It’s okay to use transitions to move physics objects as long as the physics isn’t trying to move the object at the same time your non-physics method is. Pick one or the other but not both.
You can look at the code for the Getting Started guide as a reference: https://docs.coronalabs.com/guide/programming/index.html
Rob
I thought kinematic bodies collide with dynamic bodies? I didn’t know that they don’t generate collision events. Also my code for player blaster (pBlaster) uses kinematic bodies and it works well. It collides with enemy that uses dynamic bodies.
I tried changing for ship into
ship = display.newImageRect ("images/ship.png",100,50) ship.x = display.contentWidth/2 ship.y = display.contentHeight-10 ship.name = 'ship' ship.collision=collisionHandler ship:addEventListener('collision', ship) physics.addBody(ship, "dynamic", {density = 1, friction = 0, bounce = 0}); ship.isSensor=true
and eBlaster into
local blaster = display.newImageRect( "images/ammoE.png", 20, 20 ) blaster.x = enemy.x blaster.y = enemy.y+5 blaster.name='eBlaster' physics.addBody(blaster, "dynamic"); blaster.isSensor=true transition.to( blaster, { time=5000, y=(screenH+100),transition=easing.outSine} ) blaster.collisionHandler=collisionHandler blaster:addEventListener('collision',blaster)
but it still not working. Do you have any other tips?