Setting up a function that uses global variable to display image :)

I made a global variable that looks like this:

_G.warrior = 0 I put this in Main.lua

I am using director class and i have a different scene where there is a button to make _G.warrior = 1 :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
local warriorButton = display.newImage('images/warriorButton.png')
        warriorButton.x = 675
        warriorButton.y = 100
 
localGroup:insert( warriorButton )
 
local function pressWarrior (event)
if event.phase == "ended" then
_G.warrior = 1
 
end
end
 
warriorButton:addEventListener ("touch", pressWarrior)

It looks fine. so whats the problem you are facing ?

Its not showing up the picture is not there, can you tell me how to make it greater than or equal to 1

just a quick check...
have you given _G.warrior = 1 or _G.warrior == 1 in where condition ?

to see whether the value is being set try printing _G.warrior before the if condition.
print(_G.warrior) and check the console for output.

views:1622 update:2011/10/18 15:01:22
corona forums © 2003-2011