dimanche 1 février 2015

How to access a variable declared in a module?

in my game.lua file I have:



local sprites = require("sprites.lua")


sprites.lua contains



local iceberg = display.newImage("iceberg.png")
iceberg.x = _W/2
iceberg.y = _H/2
iceberg.alpha = 1


Now, I'd like to set "iceberg.alpha" to 0 from "game.lua", but If I try, Corona returns "attempt to index global iceberg (a nil value)"


Of course, sprites.lua contains



module(..., package.seeall)


What am I doing wrong?


I've even tried to use sprites.iceberg.alpha = 0, but obviously it doesn't work.


Thank you.




Aucun commentaire:

Enregistrer un commentaire