Hello, could someone please check through this code and explain why a score is not being added when the object reaches set .y coordinate
"local function spawnEnemy()
local enemy = display.newImageRect(“images/zombie_”…imageInt…".png",50,54)
enemy.x = mr( 20, 300 ); enemy.y = -30
enemy.name = “enemy”; physics.addBody( enemy, { isSensor = true } )
if enemy.y ==_H+45 then
score = score + 10 – points for avoiding an enemy
end"
the code of the spawning works and the zombie moves down the screen, my plan was to add a score as the zombie moved off screen (I was going to do some testing on this using trial and error with different y coordinates).
Although I notice that no score is being added at all.
_H = Screen height
Score is a variable that correctly changes from other sources of code, written the same format as above but this one is not functioning unlike the others.
Any help would be highly appreciated.
Many thanks,
Daniel
