Commit fe3b6f64 authored by wjf's avatar wjf

l

parent 13fe46e0
...@@ -40,6 +40,12 @@ export class EgretMovieClip extends egret.DisplayObjectContainer { ...@@ -40,6 +40,12 @@ export class EgretMovieClip extends egret.DisplayObjectContainer {
* 所有帧数 * 所有帧数
*/ */
totalFrames: number; totalFrames: number;
/**
*
* @param imagekey 要替换的图片key值
* @param imageUrl 图片路径或_png
*/
setImage(imagekey: string, imageUrl: string): void
/** /**
* 停止 * 停止
*/ */
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -190,6 +190,27 @@ export class MovieClip extends egret.DisplayObjectContainer { ...@@ -190,6 +190,27 @@ export class MovieClip extends egret.DisplayObjectContainer {
// console.log(this) // console.log(this)
} }
/**
*
* @param imagekey 对应的imagekey
* @param imageUrl 图片路径,以后考虑支持多种形式
*/
setImage(imagekey, imageUrl) {
if (!this.textures[imagekey]) return
let texture = this.textures[imagekey]
var width = texture.textureWidth;
var height = texture.textureHeight;
getAsset(imageUrl, function (tex, key) {
//替换掉this.textures[imagekey]
this.textures[imagekey] = tex;
for (var i = 0; i < this.children.length; i++) {
let child = this.children[i]
//texture相等
if (child.texture == texture) child.texture = tex
}
}, this)
}
/** /**
* 调用止方法将停止当前帧 * 调用止方法将停止当前帧
* @method stop * @method stop
...@@ -522,3 +543,26 @@ export class MovieClip extends egret.DisplayObjectContainer { ...@@ -522,3 +543,26 @@ export class MovieClip extends egret.DisplayObjectContainer {
return true return true
} }
} }
/**
* @language zh_CN
* 解析素材
* @param source 待解析的新素材标识符
* @param compFunc 解析完成回调函数,示例:callBack(content:any,source:string):void;
* @param thisObject callBack的 this 引用
*/
function getAsset(source, compFunc, thisObject) {
if (RES.hasRes(source)) {
var data = RES.getRes(source);
if (data) {
compFunc(data, source);
}
else {
RES.getResAsync(source, compFunc, thisObject);
}
}
else {
RES.getResByUrl(source, compFunc, thisObject, RES.ResourceItem.TYPE_IMAGE);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment