mirror of
https://github.com/Leo501/CocosCreatorTutorial.git
synced 2026-06-04 08:37:28 +08:00
添加一个图片的demo
This commit is contained in:
29
ImageLoaderDemo/assets/Script/TestJS.js
Normal file
29
ImageLoaderDemo/assets/Script/TestJS.js
Normal file
@@ -0,0 +1,29 @@
|
||||
const ImageLoader = require('ImageLoader');
|
||||
cc.Class({
|
||||
extends: cc.Component,
|
||||
|
||||
properties: {
|
||||
image: cc.Sprite
|
||||
},
|
||||
|
||||
// use this for initialization
|
||||
onLoad: function () {
|
||||
|
||||
},
|
||||
|
||||
start() {
|
||||
let test = 'https://www.cocos.com/wp-content/themes/cocos/image/home/example_01.png';
|
||||
ImageLoader.remoteImage(test, (spriteFrame) => {
|
||||
this.image.spriteFrame = spriteFrame;
|
||||
}, 'png');
|
||||
|
||||
ImageLoader.loaderResImage('Image/example_02', (spriteFrame) => {
|
||||
this.image.spriteFrame = spriteFrame;
|
||||
});
|
||||
},
|
||||
|
||||
// called every frame
|
||||
update: function (dt) {
|
||||
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user