zl程序教程

您现在的位置是:首页 >  其它

当前栏目

TintTo和TintBy

2023-09-27 14:29:13 时间
//创建标签
var helloLabel = cc.LabelTTF.create("Hello World", "Arial", 38);
//设置位置
            helloLabel.setPosition(cc.p(100,100));
//添加到layer
            this.addChild(helloLabel, 5);

//改变颜色,不可reverse

             var hurtColor = cc.TintTo.create(2.5,-255,0,0);

//移动并同时改变颜色      helloLabel.runAction(cc.Spawn.create(cc.MoveBy.create(2.5, cc.p(0, 300 - 40)),
             hurtColor));

//改变颜色并回滚颜色
var action2 = cc.TintBy.create(2, -255, 0, 0);
            var action2Back = action2.reverse();
            helloLabel.runAction(cc.Sequence.create(action2, action2Back));