Whenever I input this global function it always gives me this error:
Director ERROR: Failed to execute new( params ) function on ‘home’.
This is my code in Main.lua
display.setStatusBar( display.HiddenStatusBar )
--====================================================================--
-- DIRECTOR CLASS SAMPLE
--====================================================================--
--[[
--]]
--====================================================================--
-- IMPORT DIRECTOR CLASS
--====================================================================--
local director = require("director")
--====================================================================--
-- CREATE A MAIN GROUP
--====================================================================--
local mainGroup = display.newGroup()
--====================================================================--
-- MAIN FUNCTION
--====================================================================--
local main = function ()
\_G["vars"]={}
\_G["warrior"]=0
------------------
-- Add the group from director class
------------------
mainGroup:insert(director.directorView)
------------------
-- Change scene without effects
------------------
director:changeScene("menu")
------------------
-- Return
------------------
return true
end
main()
This is my code in troops.lua (it is a popup that adds to the variable:
local function pressWarrior (event)
if event.phase == "ended"
then
print('added one')
\_G["warrior"]=\_G["warrior"]+10
end
end
And finally this is where the actual image is summoned:
[code]
local warrior = _G[“warrior”]
if(warrior > 0) then
warrior = display.newImage(‘images/warrior.png’, 480, 320)
end
_G[“warrior”]=warrior
localGroup:insert( warrior )
[/code] [import]uid: 34097 topic_id: 16258 reply_id: 316258[/import]