Skip to content

Commit

Permalink
修复少量 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
anlun214 committed May 11, 2017
1 parent c83bcb3 commit 6152969
Show file tree
Hide file tree
Showing 23 changed files with 232 additions and 598 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@
修复annie.Timer使用时用户不使用kill杀死Timer对象导致内存泄漏报错的bug
修复首次添加显示对象到舞台时,偶尔会出现残影的bug
修复开启多点手势后,在pc端打开时报错而需要刷新后才正常的bug
修复初始化annie.Bitmap时设置宽高无效的bug
新增annie.TextInput的maxCharacters最长字段属性
新增annie.Event中一些静态事件常量
新增annie.Shape的像素碰撞,默认开启.属性名为:hitTestWidthPixel
新增annie.Bitmap的像素碰撞,默认未开启.属性名为:hitTestWidthPixel
重写annieUI.SlidePage类,使其更加完善和优化
更改默认关闭旋转和默认禁止调整stage尺寸
## AnnieJS 1.0.9 版本
修复annie.Shape画线在手机端会报错的bug
修复annie.Shape在不缓存成位置下的点击区域失效的bug
Expand Down
2 changes: 1 addition & 1 deletion annie/Annie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace annie {
* width: 441,
* height: 694
* }, {
* type: "jpg"//数据类型jpg/png
* type: "jpeg"//数据类型jpg/png
* quality: 90//图片质量值1-100,png格式不需要设置quality
* }, '#CDDBEB');
*
Expand Down
43 changes: 23 additions & 20 deletions annie/display/Bitmap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,6 @@ namespace annie {
* @since 1.0.0
*/
export class Bitmap extends DisplayObject {
/**
* HTML的一个Image对象或者是canvas对象或者是video对象
* @property bitmapData
* @public
* @since 1.0.0
* @type {any}
* @default null
*/
public get bitmapData(): any {
return this._bitmapData
};
public set bitmapData(value: any) {
this._setProperty("_bitmapData",value,3);
if (!value) {
this._bounds.width = this._bounds.height = 0;
}
}

private _bitmapData: any = null;
private _realCacheImg: any = null;
/**
Expand Down Expand Up @@ -84,8 +66,29 @@ namespace annie {
super();
let s = this;
s._instanceType = "annie.Bitmap";
s.bitmapData = bitmapData;
s.rect = rect;
s.bitmapData = bitmapData;
}
/**
* HTML的一个Image对象或者是canvas对象或者是video对象
* @property bitmapData
* @public
* @since 1.0.0
* @type {any}
* @default null
*/
public get bitmapData(): any {
return this._bitmapData
};
public set bitmapData(value: any) {
let s=this;
s._setProperty("_bitmapData",value,3);
if (!value) {
s._bounds.width = s._bounds.height = 0;
}else{
s._bounds.width=s.rect?s.rect.width:value.width;
s._bounds.height=s.rect?s.rect.height:value.height;
}
}

/**
Expand Down Expand Up @@ -191,7 +194,7 @@ namespace annie {
s._bounds.width = bw;
s._bounds.height = bh;
//给webgl更新新
s._cacheImg.updateTexture = true;
// s._cacheImg.updateTexture = true;
}
s._updateInfo.UF = false;
s._updateInfo.UM = false;
Expand Down
6 changes: 4 additions & 2 deletions annie/display/DisplayObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,9 +549,11 @@ namespace annie {
*/
public getWH():{width:number,height:number}{
let s = this;
s.update(false,false,false);
if(s._instanceType=="annie.MovieClip") {
s.update(false, false, false);
s._updateInfo.UM = true;
}
let dr = s.getDrawRect();
s._updateInfo.UM = true;
return {width:dr.width,height:dr.height};
}
/**
Expand Down
1 change: 0 additions & 1 deletion annie/display/FloatDisplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ namespace annie {
}

}

/**
* 重写getBounds
* 获取Bitmap对象的Bounds
Expand Down
1 change: 0 additions & 1 deletion annie/display/MovieClip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,6 @@ namespace annie {
let s = this;
s._graphicInfo = graphicInfo;
}

/**
* 将一个mc变成按钮来使用 如果mc在于2帧,那么点击此mc将自动有被按钮的状态,无需用户自己写代码
* @method initButton
Expand Down
100 changes: 52 additions & 48 deletions annie/display/Shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ namespace annie {
}
return colorObj;
}

/**
* 设置位图填充时需要使用的方法,一般给用户使用较少,Flash2x工具自动使用
* @method getBitmapStyle
Expand All @@ -63,6 +64,7 @@ namespace annie {
let ctx = DisplayObject["_canvas"].getContext("2d");
return ctx.createPattern(image, "repeat");
}

/**
* 通过24位颜色值和一个透明度值生成RGBA值
* @method getRGBA
Expand Down Expand Up @@ -98,7 +100,8 @@ namespace annie {
* @default true
* @since 1.1.0
*/
public hitTestWidthPixel:boolean=true;
public hitTestWidthPixel: boolean = true;

/**
* 添加一条绘画指令,具体可以查阅Html Canvas画图方法
* @method addDraw
Expand Down Expand Up @@ -660,7 +663,7 @@ namespace annie {
public update(um: boolean, ua: boolean, uf: boolean): void {
let s = this;
super.update(um, ua, uf);
if (s._isNeedUpdate||uf|| s._updateInfo.UF) {
if (s._isNeedUpdate || uf || s._updateInfo.UF) {
//更新缓存
let cLen: number = s._command.length;
let leftX: number;
Expand Down Expand Up @@ -777,52 +780,52 @@ namespace annie {
s._cacheY = leftY;
s._bounds.width = w - 10;
s._bounds.height = h - 10;
///////////////////////////
if (!s._cacheImg) {
s._cacheImg = window.document.createElement("canvas");
}
let _canvas = s._cacheImg;
//给webgl更新新
_canvas.updateTexture = true;
let ctx = _canvas["getContext"]('2d');
_canvas.width = w;
_canvas.height = h;
_canvas.style.width = w / devicePixelRatio + "px";
_canvas.style.height = h / devicePixelRatio + "px";
ctx.clearRect(0, 0, w, h);
ctx.setTransform(1, 0, 0, 1, -leftX, -leftY);
/////////////////////
let cf = s.cFilters;
let cfLen = cf.length;
if (cfLen > 0) {
for (let i = 0; i < cfLen; i++) {
if (s.cFilters[i].type == "Shadow") {
ctx.shadowBlur += cf[i].blur;
ctx.shadowColor += cf[i].color;
ctx.shadowOffsetX += cf[i].offsetX;
ctx.shadowOffsetY += cf[i].offsetY;
break;
}
///////////////////////////
if (!s._cacheImg) {
s._cacheImg = window.document.createElement("canvas");
}
let _canvas = s._cacheImg;
let ctx = _canvas["getContext"]('2d');
_canvas.width = w;
_canvas.height = h;
_canvas.style.width = w / devicePixelRatio + "px";
_canvas.style.height = h / devicePixelRatio + "px";
ctx.clearRect(0, 0, w, h);
ctx.setTransform(1, 0, 0, 1, -leftX, -leftY);
/////////////////////
let cf = s.cFilters;
let cfLen = cf.length;
if (cfLen > 0) {
for (let i = 0; i < cfLen; i++) {
if (s.cFilters[i].type == "Shadow") {
ctx.shadowBlur += cf[i].blur;
ctx.shadowColor += cf[i].color;
ctx.shadowOffsetX += cf[i].offsetX;
ctx.shadowOffsetY += cf[i].offsetY;
break;
}
} else {
ctx.shadowBlur = 0;
ctx.shadowColor = "#0";
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
}
////////////////////
s._drawShape(ctx);
///////////////////////////
//滤镜
let len = s.cFilters.length;
if (len > 0) {
let imageData = ctx.getImageData(0, 0, w, h);
for (let i = 0; i < len; i++) {
let f: any = s.cFilters[i];
f.drawFilter(imageData);
}
ctx.putImageData(imageData, 0, 0);
} else {
ctx.shadowBlur = 0;
ctx.shadowColor = "#0";
ctx.shadowOffsetX = 0;
ctx.shadowOffsetY = 0;
}
////////////////////
s._drawShape(ctx);
///////////////////////////
//滤镜
let len = s.cFilters.length;
if (len > 0) {
let imageData = ctx.getImageData(0, 0, w, h);
for (let i = 0; i < len; i++) {
let f: any = s.cFilters[i];
f.drawFilter(imageData);
}
ctx.putImageData(imageData, 0, 0);
}
//给webgl更新新
// _canvas.updateTexture = true;
}
}
s._isNeedUpdate = false;
Expand All @@ -831,6 +834,7 @@ namespace annie {
s._updateInfo.UA = false;
s._updateInfo.UF = false;
}

private _drawShape(ctx: any, isMask: boolean = false): void {
let s = this;
let com = s._command;
Expand Down Expand Up @@ -894,7 +898,7 @@ namespace annie {
let p = s.globalToLocal(globalPoint);
p.x -= s._cacheX;
p.y -= s._cacheY;
if (s.getBounds().isPointIn(p)){
if (s.getBounds().isPointIn(p)) {
if (s.hitTestWidthPixel) {
let image = s._cacheImg;
if (!image || image.width == 0 || image.height == 0) {
Expand All @@ -905,12 +909,12 @@ namespace annie {
_canvas.height = 1;
let ctx = _canvas["getContext"]('2d');
ctx.clearRect(0, 0, 1, 1);
ctx.setTransform(1, 0, 0, 1, - p.x, - p.y);
ctx.setTransform(1, 0, 0, 1, -p.x, -p.y);
ctx.drawImage(image, 0, 0);
if (ctx.getImageData(0, 0, 1, 1).data[3] > 0) {
return s;
}
}else {
} else {
return s;
}
}
Expand Down
15 changes: 8 additions & 7 deletions annie/display/Stage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,24 +92,24 @@ namespace annie {
*/
public isMultiTouch: boolean = false;
/**
* 当设备尺寸更新,或者旋转后是否自动更新方向
* 当设备尺寸更新,或者旋转后是否自动更新舞台方向
* 端默认不开启
* @property autoSteering
* @public
* @since 1.0.0
* @type {boolean}
* @default true
* @default false
*/
public autoSteering: boolean = true;
public autoSteering: boolean = false;
/**
* 当设备尺寸更新,或者旋转后是否自动更新尺寸。
* 当设备尺寸更新,或者旋转后是否自动更新舞台尺寸
* @property autoResize
* @public
* @since 1.0.0
* @type {boolean}
* @default true
* @default false
*/
public autoResize: boolean = true;
public autoResize: boolean = false;
/**
* 舞台的尺寸宽,也就是我们常说的设计尺寸
* @property desWidth
Expand Down Expand Up @@ -257,7 +257,8 @@ namespace annie {
s.renderObj = new CanvasRender(s);
} else {
//webgl
s.renderObj = new WGRender(s);
trace("noSupport");
// s.renderObj = new WGRender(s);
}
s.renderObj.init();
window.addEventListener(resizeEvent, function (e: any) {
Expand Down
2 changes: 1 addition & 1 deletion annie/display/TextField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ namespace annie {
s._cacheY = -10;
s._isNeedUpdate = false;
//给webgl更新新
s._cacheImg.updateTexture = true;
// s._cacheImg.updateTexture = true;
s._bounds.height = maxH;
s._bounds.width = maxW;
}
Expand Down
10 changes: 6 additions & 4 deletions annie/display/VideoPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ namespace annie {
/**
* @method VideoPlayer
* @param {string} src
* @param {number} type 视频类型 值为0则会自动检测android下用序列图,其他系统下支持mp4的用mp4,不支持mp4的用序列图\n,值为1时全部使用序列图,值为2时全部使用mp4
* @param {number} type 视频类型 值为0则会自动检测android下用序列图,其他系统下支持mp4的用mp4,不支持mp4的用序列图,值为1时全部使用序列图,值为2时全部使用mp4
* @param {number} width
* @param {number} height
*/
public constructor(src:any,type:number=0,width:number,height:number){
public constructor(src:any,type:number,width:number,height:number){
super();
let s=this;
s._instanceType="annie.VideoPlayer";
Expand All @@ -34,11 +34,13 @@ namespace annie {
isUseVideo=false;
}
if(isUseVideo){
s.video=new Video(src+".mp4",width,height);
s.video=new Video(src+".mp4",1,1);
}else{
s.video=new ImageFrames(src,width,height);
s.video=new ImageFrames(src);
}
s.videoType=isUseVideo?1:0;
s._bounds.width=width;
s._bounds.height=height;
}
/**
* 视频的引用
Expand Down
8 changes: 8 additions & 0 deletions annie/events/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ namespace annie {
* @type {string}
*/
public static ON_PLAY_END="onPlayEnd";
/**
* annie.Media相关媒体类的开始播放事件。像annie.Sound annie.Video都可以捕捉这种事件。
* @property ON_PLAY_START
* @static
* @since 1.1.0
* @type {string}
*/
public static ON_PLAY_START="onPlayStart";
/**
* annieUI.FlipBook组件翻页开始事件
* @property ON_FLIP_START
Expand Down
6 changes: 2 additions & 4 deletions annie/media/ImageFrames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,16 +97,14 @@ namespace annie {
* 被始化一个序列图视频
* @method ImageFrames 构架函数
* @param src
* @param width
* @param height
* @since 1.0.0
*/
public constructor(src:string,width:number,height:number) {
public constructor(src:string) {
super();
let s = this;
s._instanceType="annie.ImageFrames";
s.src=src;
s.rect = new Rectangle(0,0,width,height);
s.rect = new Rectangle();
s.list = [];
s._urlLoader = new URLLoader();
s._urlLoader.addEventListener(annie.Event.COMPLETE, s.success.bind(s));
Expand Down
Loading

0 comments on commit 6152969

Please sign in to comment.