cc.Class({
extends: cc.Component,
properties: {
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
//1.这是加载精灵帧
var sp=cc.find("iamg");
cc.loader.loadRes("head_7",cc.SpriteFrame,function(err,frame)
{
sp.getComponent(cc.Sprite).spriteFrame=frame;
})
//2.合图加载
var sp1=cc.find("otherSprite");
//第一个参是合图名字,第二个是类型,第三个是回掉函数
cc.loader.loadRes("ZD",cc.SpriteAtlas,function(err,Altas)//这是加载合图里面的精灵帧
{
sp1.getComponent(cc.Sprite).spriteFrame=Altas.getSpriteFrame("zhad-9");
}.bind(this)))
//3.这是网络加载图片
var spr2=cc.find("New Sprite");
cc.loader.load("http://news.yule.com.cn/uploadfile/2017/0822/20170822043453866.jpg",
function(err,texture){
var fra=spr2.getComponent(cc.Sprite);
var sframe=new cc.SpriteFrame(texture,new cc.Rect(0,0,texture.width,texture.height),false,cc.Vec2.ZERO,new cc.Size(texture.width,texture.height/2));
fra.spriteFrame=sframe;
})
},
// update (dt) {},
});