Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- IN GAMELOGIC FILE
- --]]
- require "fire"
- --way down in the code:
- --I have a fire button that will trigger a bullet initialzed
- -- from the fire class and the public constructor :new() of the object
- function buttonActionPress( event )
- if (nil ~= player) then
- if ( event.phase =="began" ) then
- print("fireeee")
- local bullet = Fire:new(-- GUESS HERES THE PROBLEM OF PARSING THE BULLETS CORDS )
- function onBulletCollision( self, event )
- if ( event.phase == "began" ) then
- if(event.other.lhTag == LevelHelper_TAG.ENEMY) then
- event.other:removeSelf()
- event.other = nil
- score:addPoints(500)
- end
- end
- end
- end
- end
- end
- function playerMovement()
- if player.state == STATE_WALKING then
- --player:applyForce(player.direction * 5, 0, player.x, player.y)
- firePos = player.x
- player.x = player.x + motionx
- if(nil ~= backgroundPLX)then
- if player.direction == DIRECTION_RIGHT then
- backgroundPLX:setPosition( backgroundPLX.position.x - .2, backgroundPLX.position.y)
- elseif player.direction == DIRECTION_LEFT then
- backgroundPLX:setPosition( backgroundPLX.position.x + .2, backgroundPLX.position.y)
- end
- end
- if(nil ~= foregroundPLX)then
- if player.direction == DIRECTION_RIGHT then
- foregroundPLX:setPosition( foregroundPLX.position.x - .6, foregroundPLX.position.y)
- elseif player.direction == DIRECTION_LEFT then
- foregroundPLX:setPosition( foregroundPLX.position.x + .6, foregroundPLX.position.y)
- end
- end
- end
- end
- Runtime:addEventListener("enterFrame", playerMovement)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement