Hello everyone this is my first post.
I am trying to add an image in a touch event. When the even fires it says that the image cannot be found.
The image loads fine when it is added outside of the event.
Here is the code:
[lua]local physics = require (“physics”)
physics.start()
local floor = display.newImage(“ground.png”, 0, 800)
physics.addBody(floor, “static”)
local red_button = display.newImage(“red_button.png”, 324, 685)
– image loads and displays fine here
local ball = display.newImage(“ball.png”)
ball.x = math.ceil(red_button.x)
ball.y = math.ceil(red_button.y)
physics.addBody(ball)
function onButtonClick(event)
– error happens here
– WARNING: Failed to find image(ball.png)
local ball = display.newImage(“ball.png”, red_button.x, red_button.y)
end
red_button:addEventListener(“touch”, onButtonClick)[/lua]
Any help here would be greatly appreciated! [import]uid: 37867 topic_id: 7244 reply_id: 307244[/import]