Commit d711ec43 authored by wjf's avatar wjf

l

parent 81c8fc27
import {DisplayObject} from './DisplayObject'; import { DisplayObject } from './DisplayObject';
import {Rectangle} from "../math/Rectangle"; import { Rectangle } from "../math/Rectangle";
import {Point} from '../math'; import { Point } from '../math';
import CanvasRenderer from '../renderers/CanvasRenderer'; import CanvasRenderer from '../renderers/CanvasRenderer';
import {Event} from "../events/Event" import { Event } from "../events/Event"
import {WebglRenderer} from '../renderers/WebglRenderer'; import { WebglRenderer } from '../renderers/WebglRenderer';
/** /**
* 容器类 * 容器类
...@@ -538,17 +538,17 @@ export default class Container extends DisplayObject { ...@@ -538,17 +538,17 @@ export default class Container extends DisplayObject {
* @member {number} * @member {number}
*/ */
get width() { get width() {
return this.scale.x * this.getLocalBounds().width; return this._width || this.scale.x * this.getLocalBounds().width;
} }
set width(value) { set width(value) {
const width = this.getLocalBounds().width; // const width = this.getLocalBounds().width;
if (width !== 0) { // if (width !== 0) {
this.scale.x = value / width; // this.scale.x = value / width;
} else { // } else {
this.scale.x = 1; // this.scale.x = 1;
} // }
//子类有用,有_width,才需设置scaleX //子类有用,有_width,才需设置scaleX
this._width = value this._width = value
} }
...@@ -558,17 +558,17 @@ export default class Container extends DisplayObject { ...@@ -558,17 +558,17 @@ export default class Container extends DisplayObject {
* @member {number} * @member {number}
*/ */
get height() { get height() {
return this.scale.y * this.getLocalBounds().height; return this._height || this.scale.y * this.getLocalBounds().height;
} }
set height(value) { set height(value) {
const height = this.getLocalBounds().height; // const height = this.getLocalBounds().height;
if (height !== 0) { // if (height !== 0) {
this.scale.y = value / height; // this.scale.y = value / height;
} else { // } else {
this.scale.y = 1; // this.scale.y = 1;
} // }
this._height = value this._height = value
} }
......
...@@ -122,15 +122,14 @@ export default class Sprite extends Container { ...@@ -122,15 +122,14 @@ export default class Sprite extends Container {
this._textureTrimmedID = -1; this._textureTrimmedID = -1;
//可用才赋值uv //可用才赋值uv
if (this._texture.valid) this.uvs = this._texture._uvs.uvsFloat32; if (this._texture.valid) this.uvs = this._texture._uvs.uvsFloat32;
//设置过宽高的话,就需要改变缩放值 //设置过宽高的话,就需要改变缩放值,废弃先
// so if _width is 0 then width was not set.. // if (this._width) {
if (this._width) { // this.scale.x = sign(this.scale.x) * this._width / this._texture.orig.width;
this.scale.x = sign(this.scale.x) * this._width / this._texture.orig.width; // }
}
if (this._height) { // if (this._height) {
this.scale.y = sign(this.scale.y) * this._height / this._texture.orig.height; // this.scale.y = sign(this.scale.y) * this._height / this._texture.orig.height;
} // }
//修改_localBoundsSelf //修改_localBoundsSelf
const width = this._texture.orig.width; const width = this._texture.orig.width;
...@@ -369,34 +368,34 @@ export default class Sprite extends Container { ...@@ -369,34 +368,34 @@ export default class Sprite extends Container {
} }
/** /**
* 重写Container父类 * 重写Container父类,废弃先
* texture的宽度和缩放乘积 * texture的宽度和缩放乘积
* @member {number} * @member {number}
*/ */
get width() { // get width() {
return Math.abs(this.scale.x) * this._texture.orig.width; // return Math.abs(this.scale.x) * this._texture.orig.width;
} // }
set width(value) { // set width(value) {
const s = sign(this.scale.x) || 1; // const s = sign(this.scale.x) || 1;
this.scale.x = s * value / this._texture.orig.width; // this.scale.x = s * value / this._texture.orig.width;
this._width = value; // this._width = value;
} // }
/** /**
* texture的高度和缩放乘积 * texture的高度和缩放乘积
* @member {number} * @member {number}
*/ */
get height() { // get height() {
return Math.abs(this.scale.y) * this._texture.orig.height; // return Math.abs(this.scale.y) * this._texture.orig.height;
} // }
set height(value) { // set height(value) {
const s = sign(this.scale.y) || 1; // const s = sign(this.scale.y) || 1;
this.scale.y = s * value / this._texture.orig.height; // this.scale.y = s * value / this._texture.orig.height;
this._height = value; // this._height = value;
} // }
/** /**
* 0,0标识左上角,0.5,0.5表示中间,1,1表示右下角 * 0,0标识左上角,0.5,0.5表示中间,1,1表示右下角
......
...@@ -1378,36 +1378,36 @@ export default class Graphics extends Container { ...@@ -1378,36 +1378,36 @@ export default class Graphics extends Container {
/** /**
* The width of the sprite, setting this will actually modify the scale to achieve the value set * 废弃先
* @member {number} * @member {number}
*/ */
get width() { // get width() {
this.updateLocalBoundsSelf() // this.updateLocalBoundsSelf()
return Math.abs(this.scale.x) * this._localBoundsSelf.width; // return Math.abs(this.scale.x) * this._localBoundsSelf.width;
} // }
set width(value) { // set width(value) {
const s = sign(this.scale.x) || 1; // const s = sign(this.scale.x) || 1;
this.scale.x = s * value / this._localBoundsSelf.width; // this.scale.x = s * value / this._localBoundsSelf.width;
this._width = value; // this._width = value;
} // }
/** /**
* The height of the sprite, setting this will actually modify the scale to achieve the value set * The height of the sprite, setting this will actually modify the scale to achieve the value set
* *
* @member {number} * @member {number}
*/ */
get height() { // get height() {
this.updateLocalBoundsSelf() // this.updateLocalBoundsSelf()
return Math.abs(this.scale.y) * this._localBoundsSelf.height; // return Math.abs(this.scale.y) * this._localBoundsSelf.height;
} // }
set height(value) { // set height(value) {
const s = sign(this.scale.y) || 1; // const s = sign(this.scale.y) || 1;
this.scale.y = s * value / this._localBoundsSelf.height; // this.scale.y = s * value / this._localBoundsSelf.height;
this._height = value; // this._height = value;
} // }
/** /**
* Process the holes data. * Process the holes data.
......
...@@ -27,7 +27,7 @@ export class Shape extends Sprite { ...@@ -27,7 +27,7 @@ export class Shape extends Sprite {
constructor() { constructor() {
super(); super();
this._instanceType = "ShapeNode"; this._instanceType = "Shape";
var canvas = document.createElement('canvas'); var canvas = document.createElement('canvas');
canvas.width = 3; canvas.width = 3;
canvas.height = 3; canvas.height = 3;
......
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