我是cocos-js的新手。
我想在cocos JS中创建一个健康栏并尝试此代码。我选择使用进度计时器。但是当我使用这个代码时,它只显示条形图,没有运行动作。怎么了?
var healthBar = cc.ProgressTimer.create(cc.Sprite.create("health_bar1.png"));
healthBar.setType(cc.PROGRESS_TIMER_TYPE_BAR);
healthBar.setBarChangeRate(cc.p(1,0));
healthBar.setMidpoint(cc.p(0,0));
this.addChild(healthBar, 1);
healthBar.setPosition(cc.winSize.width/2, cc.winSize.height/2);
var to1 = cc.progressTo(5, 100);
healthBar.runAction(to1);
答案 0 :(得分:0)
这段代码非常适合我:
var healthBar = cc.ProgressTimer.create(cc.Sprite.create("health_bar1.png"));
healthBar.setType(cc.ProgressTimer.TYPE_BAR);
healthBar.setBarChangeRate(cc.p(1,0));
healthBar.setMidpoint(cc.p(0,0));
healthBar.setPosition(cc.winSize.width/2, cc.winSize.height/2);
this.getParent().addChild(healthBar, 1);
var to1 = cc.progressTo(5, 100);
healthBar.runAction(to1);