Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
Fixed bug in SingleFrameCharacter
  • Loading branch information
D5Power committed Jun 17, 2020
1 parent 9ec1c2b commit ee41efe
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions D5/src/com/d5power/objects/SingleFrameCharacter.ts
Expand Up @@ -2,7 +2,9 @@ module d5power
{
export class SingleFrameCharacter extends GameObject implements IGD
{

private _skinReady:boolean = false;
private _offX:number;
private _offY:number;
public constructor(map:IMap)
{
super(map);
Expand All @@ -12,25 +14,35 @@ module d5power

public setSkin(path:string):void
{
var data:D5UIResourceData = D5UIResourceData.getData(name);
var data:D5UIResourceData = D5UIResourceData.getData(path);
if(data==null)
{
trace("[D5Bitmap]No Resource"+name);
var texture:egret.Texture = RES.getRes(name);
trace("[D5Bitmap]No Resource"+path);
var texture:egret.Texture = RES.getRes(path);
if(texture)
{
(<egret.Bitmap>this._monitor).texture = texture;
this.onResReady(texture);
}else
{
RES.getResByUrl(name,this.onResReady,this,RES.ResourceItem.TYPE_IMAGE);
RES.getResByUrl(path,this.onResReady,this,RES.ResourceItem.TYPE_IMAGE);
}
return;
}
(<egret.Bitmap>this._monitor).texture = data.getResource(0);
}

private _lastTimer:number;
public run(t:number):void
{
if(!this._skinReady) return;
this.updatePos(this._offX,this._offY);
}

private onResReady(data:egret.Texture):void
{
this._skinReady = true;
this._offX = -data.textureWidth>>1;
this._offY = -data.textureHeight;
(<egret.Bitmap>this._monitor).texture = data;
}
}
Expand Down

0 comments on commit ee41efe

Please sign in to comment.