Thanks alot William, this does the job beautifully! But yeah, walls should be fixed…
For collision. This is the code you’d want to use:
local function functionName(event)
if(event.phase == "began") then
local variable = display.newText("Hi")
end
end
collidingObjectName.collision = functionName
collidingObjectName:addEventListener("collision", functionName)
What this code does, is it creates a function that is triggered every time your colliding object collides. IF, the event is in the phase “began”, then whatever inside that if-statement happens. Lastly in that code we tell the program that collidingObjectName’s collision attribute IS functionName. They are the same thing, when collidingObjectName collides, then functionName. And then we add an event listener that keeps checking this function over and over forever.
If you want something to happen when an object collides with a specific thing for example that blue box, then all you need to do is give the blue box a class:
blueBox = display.newImage("bluebox.png")
blueBox.class = "blueBox"
then simply add this to the first code:
if(event.phase == "began" and event.other.class == "blueBox") then
:)/Pjer [import]uid: 30185 topic_id: 5100 reply_id: 19653[/import]