cocos2d-js , Progress Timer Cocos JS v3
Progress Timer Cocos JS v3
Question:
Tag: cocos2d-js
I'm newbie in cocos-js.
I want to make a health bar in cocos JS and try this code. And i choose to use Progress Timer. But when i use this code, it just show the bar, no running action. What's wrong ?
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);
Answer:
This code is working for me very well:
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);
Related:
c++,cocos2d-x,cocos2d-x-3.0,cocos2d-android,cocos2d-js
I am new in cocos2dx development.I almost learn all basic level of cocos2dx (version 3.3) in android using cpp language. I showing that there are lots of update over cocos2dx.org. In android I am currently developing the tetris game using cocos2dx version 3.3, I want to know what is the...
cocos2d-js
I tried to use ScrollView, TableView from cocos2d-js extensions and I noticed that it can't be seen! I also tried to create a class from that example but i need to use from native class!...
javascript,local-storage,cocos2d-x,cocos2d-js
I’m converting my game from cocos2d-x 2.2.3 to cocos2d-js 3.2, but the players already have saved progress using the old CCUserDefaults. Now that I have to use localStorage in cocos2d-js, how can I read the old data that was saved using CCUserDefaults? I don’t want players to lose their progress...
javascript,cocos2d-x,game-physics,chipmunk,cocos2d-js
I am fairly new to cocos 2d and chipmunk. So far i have managed to create a static object and add collision handler to it. But i want to create a dynamic.``this.space = space; this.sprite = new cc.PhysicsSprite("#rock.png"); var body = new cp.StaticBody(); body.setPos(pos); this.sprite.setBody(body); this.shape = new cp.BoxShape(body, this.sprite.getContentSize().width,...
javascript,cocos2d-js
I am working on a game that allows users to define a "dictionary" of question/answer pairs. Then, users can import the "dictionary" to the Game Scene and practice with the questions inside the "dictionary". The question is how can I do this with Cocos2d-JS? Or, I should use LocalStorage API?...
android,ios,cocos2d-js
I am new cocos2d developer. I am studying cocos2d-js using cocos code Ide in windows. My programming language for cocos2d-js is javascript. Cocos code Ide provides good editing and testing enviroment to develop cocos2d-js. but I can't generate from the project in cocos code Ide to the release products...
cocos2d-x,cocos2d-x-3.0,cocos2d-js
I want to cache lot of textures in a running scene without blocking it, theoretically cc.textureCache.addImage do caching async if you call it the three arguments. This is not happening. Code: rainOfArrows: { _animFrames:[], loaded: function(){ console.log('>>>>>>>>>>>>>>LOAD!') }, load: function(){ /* Load all animation arrow sprites in memory & generate...
xml,go,unmarshalling,cocos2d-js
I try to unmarshal a XML file using xml.Unmarshal of "encoding/xml" package. The XML file starts like this: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>frames</key> <dict> <key>0</key> <dict> <key>frame</key> <string>{{0, 0}, {81, 145}}</string> <key>offset</key> <string>{0, 0}</string>...
cocos2d-js
I'm newbie in cocos-js. I want to make a health bar in cocos JS and try this code. And i choose to use Progress Timer. But when i use this code, it just show the bar, no running action. What's wrong ? 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,...
cocos2d-js
I'm very confused. Before I run an simple webonly cocos2d-js example, I was under the impression it generates the html5 + js files so I can host it everywhere or either run offline. But it is not the case, to run my example locally I have to start an cocos...