1
2
3
4
5
6
|
functiongetQueryString(name){
varreg=
new
RegExp(
"(^|&)"
+name+
"=([^&]*)(&|$)"
,
"i"
);
varr=window.location.search.substr(1).match(reg);
if
(r!=null)
return
decodeURIComponent(r[2]);
null;
};
|
varMyButtonSprite=cc.Sprite.extend({
ctor:function(fileName,title,fontName,fontSize){
this
._super(fileName);
vartitleLabel=
cc.LabelTTF(title,fontSize);
.addChild(titleLabel);
titleLabel.x=
.getContentSize().width/2;
titleLabel.y=
.getContentSize().height/2;
}
});
|
3、远程图片加载
loadImgFromUrl:function(target,imgUrl,p,tag){
(!imgUrl)
;
varself=target;
varloadCb=function(err,img){
cc.textureCache.addImage(imgUrl);
vartexture2d=
cc.Texture2D();
texture2d.initWithElement(img);
texture2d.handleLoadedTexture();
varsp=
cc.Sprite();
sp.initWithTexture(texture2d);
self.addChild(sp);
sp.x=p.x;
sp.y=p.y;
sp.tag=tag;
};
cc.loader.loadImg(imgUrl,{isCrossOrigin:
false
},loadCb);
|