On Sep 22, 3:57 am, claudio canepa <[email protected]> wrote:
> On 21 sep, 19:13, karan <[email protected]> wrote:
>
> > I want to create a menu in which 6 things are displayed, and as the
> > user presses up/down, the color of that thing changes. For example, if
> > the current thing is new game, its color will be blue, the colors of
> > rest of them will be green. if the user presses down, the next thing
> > becomes blue and rest of them become green.
>
> > for this, whenever the user presses down, i changed the color
> > attribute of that particular label, but when I run it, its color
> > remains the same. Is there a different way to change the color of the
> > label?
>
> I modified test_text.py which comes with cocos docs to draw in another
> color:
>
> # This code is so you can run the samples without installing the
> package
> import sys
> import os
> sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
> #
>
> import cocos
> from cocos.director import director
> from cocos.sprite import Sprite
> from cocos.actions import *
> from cocos.text import *
>
> import pyglet
>
> class TestLayer(cocos.layer.Layer):
> def __init__(self):
> super( TestLayer, self ).__init__()
>
> x,y = director.get_window_size()
>
> self.text = Label("hello", (x/2, y/2))
> self.text.element.color = (255,0,0,255)
> self.text.do( Rotate( 360, 10 ) )
> self.text.do( ScaleTo( 10, 10 ) )
> self.add( self.text )
>
> if __name__ == "__main__":
> director.init()
> test_layer = TestLayer ()
> main_scene = cocos.scene.Scene (test_layer)
> director.run (main_scene)
>
> Note that you assign color not as label.color but as
> label.element.color
> Should you have further problems, post some code.
>
> --
> claudio
Thanks! Although I created a little hack of my own in which I removed
the label and then created a new label with the other color. But your
ways reduces the code a lot.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cocos-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---