02.action-- new Wizard knowledge

Import Cocos
 from cocos.actions Import * class the HelloWorld (cocos.layer.ColorLayer):   # ColorLayer having a background color into subclasses DEF the __init__ (Self):
         # R & lt, G, B, A blue 
        super (HelloWorld, self). the __init__ (64, 64, 224, 255 )
         # to tag 
        label = cocos.text.Label (
             ' hellow, Action ' , 
            font_name = ' Times New Roman ' , 
            FONT_SIZE = 32 , 
            anchor_x



     = ' Center ' , 
            anchor_y = ' Center ' 
        ) 
        label.position = 320., 240 
        self.add (label) 
        # sprite Sprite object is 
        the sprite was dropped cocos.sprite.Sprite = ( ' cat.png ' )
         # sprite placed on the screen central is the default location (0,0) 
        sprite.position = 320., 240 # wizard to 3 times, default scale property. 1 
        sprite.scale = 3 # sprite is added as a child to the top of the label, the default value of z is 0 
        self.add (the sprite was dropped, Z =. 1 )
         # scaled objects within two seconds three times, duration: duration 
        scale = scaleBy (3, duration = 2
        
        )
         # Tab scaled three times within 2 seconds, and then reduced three times within 2 seconds, these two operations are repeatedly performed 
        # the Repeat: Repeat 
        label.do (the Repeat (Scale + Reverse (Scale)))
         # wizard first reduction reamplified 
        sprite.do (the Repeat (Reverse (Scale) + Scale)) 


DEF main ():
     # initialization director 
    cocos.director.director.init () 
    hello_layer = the HelloWorld ()
     # perform 360-degree rotation operation within 10 seconds 
    hello_layer.do (RotateBy (360, DURATION = 10 ))
     # create a scene 
    main_scene = cocos.scene.Scene (hello_layer) 
    cocos.director.director.run (main_scene) 


IF  the __name__ ==' __Main__ ' : 
    main ()

 

Guess you like

Origin www.cnblogs.com/fly-book/p/11769295.html