<html> <head> <title></title> <script type="text/javascript" src="js/cocos2d-js-v3.2-lite.js"></script> </head> <body> <canvas id="gameCanvas" width="640" height="1136"></canvas> <script> window.onload = function(){ cc.game.onStart = function(){ //load resources var px=0,py=0; cc.LoaderScene.preload(["images/bg3.jpg"], function () { var MyScene = cc.Scene.extend({ onEnter:function () { this._super(); var size = cc.director.getWinSize(); var sprite1 = cc.Sprite.create("images/bg3.jpg"); sprite1.setPosition(cc.p(size.width/2,size.height/2)); this.addChild(sprite1); var sprite2 = cc.Sprite.create("images/20131223200806312.png"); sprite2.setPosition(cc.p(size.width/2,size.height/2)) this.addChild(sprite2); var sprite3 = cc.Sprite.create("images/20131223200714671.png"); var p = cc.ProgressTimer.create(sprite3); p.setType(cc.ProgressTimer.TYPE_BAR); p.setMidpoint(cc.p(0,1)); p.setPosition(cc.p(size.width/2,size.height/2)); p.setPercentage(50); this.addChild(p,0); } }); cc.director.runScene(new MyScene()); }, this); }; cc.game.run("gameCanvas"); }; </script> </body> </html>
项目是微信的小游戏.要加个进度条..
sprite2是空状态
sprite3是满状态
sprite3这段代码不起效果.满状态的图片显示不出来..不知道哪里错啊...
即使我把p.setType(cc.ProgressTimer.TYPE_BAR);里面的参数改为其他数字,,比如222,就可以显示,但是 p.setPercentage(50);这个没效果..这个不是显示血量百分比吗?现在设置50%,,但是它显示100%了