Hi! I just recently started development on the Corona sdk and I already have a question. I made a control like in docementation on a corona web site:
local function dragShip(event) local ship = event.target local phase = event.phase if ("began" == phase) then display.currentStage:setFocus(ship) ship.touchOffsetY = event.y - ship.y elseif ("moved" == phase) then ship.y = event.y - ship.touchOffsetY elseif ("ended" == phase or "cancelled" == phase) then display.currentStage:setFocus(nil) end return true end
And then I made a button for shooting:
fire = widget.newButton{ shape = 'circle', radius = 50, x = display.contentWidth - 40, y = display.contentHeight - display.contentHeight / 5, onPress = function(event) local newLaser = display.newImageRect(mainGroup, "png/shipLaser.png", 35, 7) physics.addBody(newLaser, "dynamic", {isSensor = true}) newLaser.isBullet = true newLaser.myName = "shipLaser" newLaser.x = ship.x newLaser.y = ship.y newLaser:toBack() display.currentStage:setFocus(fire) transition.to(newLaser, {x = display.contentWidth + 300, time = 500, onComplete = function() display.remove(newLaser) end }) end }
And there’s a promlem: the movement of the box and shooting can not occur at the same time, that is, while I’m moving the ship, I can’t shoot. Hrlp me pleeaase!