标签:加载 texture script color load component 网络图片 localhost .class
1.动态加载图片
cc.Class({ extends: cc.Component, properties: { label: { default: null, type: cc.Label }, logo: { default: null, type: cc.Sprite }, // defaults, set visually when attaching this script to the Canvas text: ‘Hello, World!‘ }, // use this for initialization onLoad: function () { var self = this; //加载本地图片能成功 cc.loader.loadRes("Texture/HelloWorld", cc.SpriteFrame, function (err, spriteFrame) { self.logo.spriteFrame = spriteFrame; }); //加载网络图片成功 var url = "http://localhost:3274/"; cc.loader.load({url: url, type: ‘png‘}, function(err,img){ var mylogo = new cc.SpriteFrame(img); self.logo.spriteFrame = mylogo; }); }, // called every frame update: function (dt) { }, });
标签:加载 texture script color load component 网络图片 localhost .class
原文地址:http://www.cnblogs.com/zhuawang/p/7574201.html