print("statement not printing :( ")

I decided to to take a refresher course on if things are being deleted when they leave the screen I placed a print statement to see if things are being deleted and nothing printed!

CAN SOMEONE PLEASE TELL ME WHY :slight_smile:

CODE HERE:
[lua]_W = display.contentWidth
_H = display.contentHeight
local physics = require(“physics”)
physics.start()
local bombs = {}
local bombGroup = display.newGroup()

local function spawnBomb()
local bomb = display.newImage(“apple.png”)
bomb.x = math.random(_W/2, _W/2)
bomb.name = “bomb”
physics.addBody(bomb, {bounce=0})
bomb.bodyType = “kinematic”
bomb.isSensor = true
bomb.y = math.random(-100, -10)
bomb.index = #bombs + 1
bombGroup:insert(bomb)

bomb:setLinearVelocity(0, math.random(100, 110))
function onCollision(e)
if e.phase == “began” then
bomb:removeSelf()
bomb = nil
end
end
bomb:addEventListener(“collision”, onCollision)

bombs[bomb.index] = bomb

return bomb

end
tmrSpawnBomb = timer.performWithDelay(1000, spawnBomb, 0)

local function onEnterFrame(event)
if bombs[i]==nil then
for i, v in pairs(bombs) do
–if bomb leaves right side of screen
if bombs[i].x + bombs[i].width / 2 > display.contentWidth then
print(“apples removed”)
bombs[i]:removeSelf()
table.remove(bombs, i)
bombs[i] = nil
end
end
end
end

Runtime:addEventListener(“enterFrame”,onEnterFrame)[/lua] [import]uid: 51459 topic_id: 16697 reply_id: 316697[/import]

we are aware. thanks.

we are looking into it.

C. [import]uid: 24 topic_id: 16697 reply_id: 62483[/import]

I think line 36 should be:

[lua]if bombs ~= nil then [/lua]

Raúl Beltrán
MIU Games [import]uid: 44101 topic_id: 16697 reply_id: 62484[/import]

Hey C!

LOVE CORONA!!

@Miu Games

it didn’t work :frowning:

do I have it in the right location

[lua]_W = display.contentWidth
_H = display.contentHeight
local physics = require(“physics”)
physics.start()
local bombs = {}
local bombGroup = display.newGroup()

local function spawnBomb()
local bomb = display.newImage(“apple.png”)
bomb.x = math.random(_W/2, _W/2)
bomb.name = “bomb”
physics.addBody(bomb, {bounce=0})
bomb.bodyType = “kinematic”
bomb.isSensor = true
bomb.y = math.random(-100, -10)
bomb.index = #bombs + 1
bombGroup:insert(bomb)

bomb:setLinearVelocity(0, math.random(100, 110))
function onCollision(e)
if e.phase == “began” then
bomb:removeSelf()
bomb = nil
end
end
bomb:addEventListener(“collision”, onCollision)

bombs[bomb.index] = bomb

return bomb

end
tmrSpawnBomb = timer.performWithDelay(1000, spawnBomb, 0)

local function onEnterFrame(event)
if bombs[i] ~= nil then
for i, v in pairs(bombs) do
–if bomb leaves right side of screen
if bombs[i].x + bombs[i].width / 2 > display.contentWidth then
print(“apples removed”)
bombs[i]:removeSelf()
table.remove(bombs, i)
bombs[i] = nil
end
end
end
end

Runtime:addEventListener(“enterFrame”,onEnterFrame)[/lua]
Jake [import]uid: 51459 topic_id: 16697 reply_id: 62488[/import]

I made a mistake on my previuos post, I meant

[lua]if bombs ~= nil then[/lua]

Also, on line 39 you are checking each bomb’s X position against the screen width, but the apples are falling (X position never changes), you sholud check the bomb’s Y position against screen height instead…

Raúl Beltrán [import]uid: 44101 topic_id: 16697 reply_id: 62493[/import]

Print statement is now showing up!!

THANKS [import]uid: 51459 topic_id: 16697 reply_id: 62497[/import]

Let us know when the game is available! [import]uid: 59140 topic_id: 16697 reply_id: 62543[/import]