cocos creator基础-(六)cc.Sprite使用
1: 了解cc.Sprite的使用; ? cc.Sprite 1: 游戏中显示一个图片,通常我们把这个叫做”精灵” sprite ? 图片模式 1: simple: 精灵最普通的模式,选择该模式后,图片将缩放到指定的大小; ? 九宫格的使用 1: 指定拉伸区域,让图片在拉伸的时候某些区域不会改变; ? Filled模式 1: 配置Filled模式 cc.Class({ extends: cc.Component,properties: { // foo: { // default: null,// The default value will be used only when the component attaching // to a node for the first time // url: cc.Texture2D,// optional,default is typeof default // serializable: true,default is true // visible: true,default is true // displayName: ‘Foo‘,// optional // readonly: false,default is false // }, // ... sprite: { default: null,type: cc.Sprite,},action_time: 15,// use this for initialization onLoad: function () { // 获取组件的实例,代码获取,编辑器绑定 var node = this.node.getChildByName("time_bar"); this.sp = node.getComponent(cc.Sprite); // end // this.now_time = 0; this.now_time = this.action_time; },// called every frame,uncomment this function to activate update callback update: function (dt) { /*this.now_time += dt; var percent = this.now_time / this.action_time; // -->百分比 if (percent >= 1) { percent = 1; this.now_time = 0; // 重新开始 } this.sp.fillRange = percent; */ this.now_time -= dt; // 顺时针转动- 逆时针+ var percent = this.now_time / this.action_time; // -->百分比 if (percent <= 0) { this.now_time = this.action_time; // 重新开始 } this.sp.fillRange = percent; },}); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |