It looks like you're new here. If you want to get involved, click one of these buttons!
local deviceWidth = application:getDeviceWidth() local deviceHeight = application:getDeviceHeight() local cube = Shape.new() cube:setFillStyle(Shape.SOLID, 0xff0000, 1) cube:beginPath() cube:moveTo(0, 0) cube:lineTo(50, 0) cube:lineTo(50, 50) cube:lineTo(0, 50) cube:lineTo(0, 0) cube:endPath() cube:setPosition(deviceWidth / 2 - 50 / 2, deviceHeight - 100) local move = false local right = false local left = false local function onMouseDown(event) move = true if event.x >= deviceWidth / 2 then right = true left = false else left = true right = false end end local function onMouseUp(event) move = false end local function onEnterFrame() if move then if right then cube:setX(cube:getX() + 10) elseif left then cube:setX(cube:getX() - 10) end end end stage:addEventListener(Event.MOUSE_DOWN, onMouseDown) stage:addEventListener(Event.MOUSE_UP, onMouseUp) stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) stage:addChild(cube) |
Comments
if that's the case you can try to instead of making move a boolean, make it an integer
so change
'local move=false' to 'local move=0'
'move=true' to 'move=move+1'
'move=false' to 'move=move-1'
'if move then' to 'if move>0 then'
does this work?
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game
Fragmenter - animated loop machine and IKONOMIKON - the memory game