hello! Can I do nested ifs in corona? Below is what im trying to accomplished.
display.setStatusBar( display.HiddenStatusBar )
–multitouch
system.activate(“multitouch”)
–physics stuff
local physics = require(“physics”)
physics.start(“true”)
–physics.setDrawMode(“hybrid”)
–insert dpad img
local up = display.newImageRect( “dpad_up.png”, 83, 83 )
up.x = 42
up.y = 411
local left = display.newImageRect( “dpad_left.png”, 83, 83 )
left.x = 162
left.y = 411
local right = display.newImageRect( “dpad_right.png”, 83, 83 )
right.x = 267
right.y = 411
–make group
local enviroment = display.newGroup()
– insert objects and make physical
local floor =display.newRect(0,350,460,10)
physics.addBody (floor, “static”, { density=0, friction = 0, bounce = 0})
floor.myName = “enviroment”
local left_wall = display.newRect(0, 0, 10, 350 )
physics.addBody (left_wall, “static”)
left_wall.myName = enviroment
local right_wall = display.newRect(310, 0, 10, 350)
physics.addBody (right_wall, “static”)
right_wall.myName = enviroment
local player = display.newRect(13, 340, 10, 10 )
player:setFillColor (123,110,2)
physics.addBody (player, {friction = 0, bounce = 0})
player.myName = “player”
–utilize group
enviroment:insert(left_wall, right_wall, floor)
–collision handling
local collisionText = display.newText(“info”,150,50,native.systemfont,16)
local function colllisionPrelim( event )
if ( event.phase == “began” ) then
collisionText.text = event.object1.myName … " & " … event.object2.myName
end
end
local function moveLeft( event )
if (collisionText.text==“enviroment & player”) then
if (event.phase == “began”) then
player:applyForce (500, 500 player.x, player.y)
end
end
end
Runtime:addEventListener(“collision”, colllisionPrelim)
Runtime:addEventListener(“touch”, moveLeft) [import]uid: 86275 topic_id: 23656 reply_id: 323656[/import]