*Hi, I'm trying to access to a variable called "score" created in a layer
from a cocos.sprite.Sprite object. I tried this: "director.scene.score",
but does not work, any help? Leave a basic code for a better understanding
of the situation:*
class Player(cocos.sprite.Sprite):
def __init__(self):
cocos.sprite.Sprite.__init__(self, "player.png", 100, 100)
*#How i access to score var here??*
class Gameplay(cocos.layer.Layer):
def __init__(self):
cocos.layer.Layer.__init__(self)
self.player = Player()
self.player.position = (director.window.width/2, 50)
self.add(self.player)
*self.score = 0*
self.schedule(self.update)
def main():
director.init(width=640, height=480)
director.window.set_mouse_visible(False)
gameplay_layer = Gameplay()
main_scene = cocos.scene.Scene(gameplay_layer)
director.run(main_scene)
if __name__ == '__main__':
main()
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/groups/opt_out.