Advertisement
Hendrix000007

fireClass GameLogic file

Jun 14th, 2013
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. --[[
  2. IN GAMELOGIC FILE
  3. --]]
  4.  
  5.  
  6. require "fire"
  7.  
  8. --way down in the code:
  9. --I have a fire button that will trigger a bullet initialzed
  10. -- from the fire class and the public constructor :new() of the object
  11.  
  12. function buttonActionPress( event )
  13.     if (nil ~= player) then
  14.             if ( event.phase =="began" ) then
  15.                 print("fireeee")
  16.                 local bullet = Fire:new(-- GUESS HERES THE PROBLEM OF PARSING THE BULLETS CORDS )
  17.                 function onBulletCollision( self, event )
  18.                     if ( event.phase == "began" ) then
  19.                         if(event.other.lhTag == LevelHelper_TAG.ENEMY) then
  20.                             event.other:removeSelf()
  21.                             event.other = nil
  22.                             score:addPoints(500)
  23.                         end
  24.                        
  25.                     end
  26.  
  27.                 end            
  28.                
  29.             end
  30.     end
  31.     end
  32.  
  33.  
  34.  function playerMovement()
  35.     if player.state == STATE_WALKING then
  36.             --player:applyForce(player.direction * 5, 0, player.x, player.y)
  37.             firePos = player.x
  38.             player.x = player.x + motionx
  39.             if(nil ~= backgroundPLX)then
  40.                 if player.direction == DIRECTION_RIGHT then
  41.                     backgroundPLX:setPosition( backgroundPLX.position.x - .2, backgroundPLX.position.y)
  42.                 elseif player.direction == DIRECTION_LEFT then
  43.                     backgroundPLX:setPosition( backgroundPLX.position.x + .2, backgroundPLX.position.y)
  44.                 end
  45.             end
  46.             if(nil ~= foregroundPLX)then
  47.                 if player.direction == DIRECTION_RIGHT then
  48.                     foregroundPLX:setPosition( foregroundPLX.position.x - .6, foregroundPLX.position.y)
  49.                 elseif player.direction == DIRECTION_LEFT then
  50.                     foregroundPLX:setPosition( foregroundPLX.position.x + .6, foregroundPLX.position.y)
  51.                 end
  52.             end
  53.            
  54.            
  55.     end
  56.     end
  57.     Runtime:addEventListener("enterFrame", playerMovement)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement