Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Knowing how the name of an object in LUA — Gideros Forum

Knowing how the name of an object in LUA

AhBadianeAhBadiane Member
edited March 2013 in General questions
In the example "Jumping Balls2" given with Gideros.
In the function "Ball: onEnterFrame (event)" I would like to know the name of ball that uses this function

I thought I could recover proporiété self.name in the funcrion "Ball: onEnterFrame (event)"

And the function "Ball: init (texture)" to the statement "self.name = self: GetName ()" - but getName does not exist! @-)
AhBadiane

Comments

  • BJGBJG Member
    edited March 2013
    Hi AhBadiane. I'm a bit out of practice with Lua at the moment (learning Java for a while) but I guess you could add a "textureName" property to the Ball class which could hold the name of the .png file which has been used to create a ball instance - something like:
    function Ball:init(texture)
       self.textureName = texture
    You could then add a "getTextureName" method which would retrieve the value of this property for a given ball; I think it's something like:
    function Ball:getTextureName()
       return self.textureName
    end
    Is this the kind of thing you mean...?

    Likes: AhBadiane

    +1 -1 (+1 / -0 )Share on Facebook
  • Is exactly that and it works well
    Thx BJG
    AhBadiane
Sign In or Register to comment.