module(...,package.seeall) function newBullet() local bullet=display.newImage("bulleth.png") bullet.x=100 bullet.y=100 bullet.type="bullet" physics.addBody(bullet,"kinematic",{density=0.2, friction=.2, bounce=.5, radius=20}) bullet.linearDampling=.3 bullet.angularDampling=.8 bullet.isBullet=true --forces continous collison detection bullet.isSensor=true function bullet:touch(event) if(event.phase=="began") then display.getCurrentStage():setFocus( event.target ) self.isFocus=true self.bodyType="kinematic" --Stop current motion if any self:setLinearVelocity(0,0) self:angularVelocity=0 --line 28 myLine=nil elseif(self.isFocus) then if(event.phase=="moved") then if (myLine) then myLine.parent:remove(myLine) --erase previous line, if any end --Check this myLine=display.newLine(self.x,self.y, event.x, event.y) myLine:setColor(255,255,255,50) myLine:width=8 elseif(event.phase=="ended" or event.phase=="cancelled") then display.getCurrentStage():setFocus(nil) self.isFocus=false if(myLine) then myLine.parent:remove(myLine) end --Launch bullet self.bodyType="dynamic" self:applyForce((self.x-event.x)\*force\_multiplier,(self.y-event.y)\*force\_multiplier, self.x, self.y) end end end bullet:addEventListener("touch", bullet) return bullet end
I am getting error in my code that says:
bullet.lua:28: function arguments expected near ‘=’
I am looking in my code and cannot see the error the system is talking about. Line 28 is marked in the code via comment.
Please help!
operator implies you’re using a function. Any time you’re changing an attribute/variable value, you always use the period (.) separator (or I guess technically you could use self[“angularVelocity”] = 0 but who wants to do the extra typing), but the colon operator is used to pass a reference to the object into the function.