After reading the blog by JB about the new way to code external “modules”, I have given this a try to display an arrow graphic. I am getting the arrow to display OK but the function to set the rotation is not working. The setRotation is definitely being called.
Any ideas what I am doing wrong?
I had posted more or less the same question on the blog but thought it would get more coverage here on the forum and would be of help to others trying to figure out this stuff.
arrow.lua
local arrow= {}
local arrow\_mt = { \_\_index = arrow } -- metatable
-------------------------------------------------
-- PUBLIC FUNCTIONS
-------------------------------------------------
function arrow.new( xPos, yPos ) -- constructor
local newArrow = display.newImageRect("images/guidearrow.png", 128,128)
newArrow.x = xPos
newArrow.y = yPos
return setmetatable( newArrow, arrow\_mt )
end
function arrow:setRotation(passedRotation)
print ("rotate")
self.rotation = passedRotation
end
return arrow
main.lua
[code]
local arrowClass = require(“arrow”)
local arrow1 = arrowClass.new( 250,250 )
arrow1:setRotation(45)
[/code] [import]uid: 7863 topic_id: 16035 reply_id: 316035[/import]