Commit d711ec43 authored by wjf's avatar wjf

l

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