Commit 4beb6018 authored by rockyl's avatar rockyl

mouseEnable 改为 mouseEnabled

parent 53470397
...@@ -1199,7 +1199,7 @@ ...@@ -1199,7 +1199,7 @@
__extends(DisplayObject, _super); __extends(DisplayObject, _super);
function DisplayObject() { function DisplayObject() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.mouseEnable = true; _this.mouseEnabled = true;
_this._components = []; _this._components = [];
_this._instanceType = "DisplayObject"; _this._instanceType = "DisplayObject";
_this.tempDisplayObjectParent = null; _this.tempDisplayObjectParent = null;
...@@ -1236,7 +1236,7 @@ ...@@ -1236,7 +1236,7 @@
var s = this; var s = this;
if (!s.visible) if (!s.visible)
return null; return null;
if (isMouseEvent && !s.mouseEnable) if (isMouseEvent && !s.mouseEnabled)
return null; return null;
if (!isMouseEvent) { if (!isMouseEvent) {
if (s._localBoundsSelf.isPointIn(point)) { if (s._localBoundsSelf.isPointIn(point)) {
...@@ -1356,7 +1356,7 @@ ...@@ -1356,7 +1356,7 @@
this._bounds = null; this._bounds = null;
this.tempDisplayObjectParent = null; this.tempDisplayObjectParent = null;
this._mask = null; this._mask = null;
this.mouseEnable = false; this.mouseEnabled = false;
this.destroyed = true; this.destroyed = true;
}; };
Object.defineProperty(DisplayObject.prototype, "alpha", { Object.defineProperty(DisplayObject.prototype, "alpha", {
...@@ -1919,6 +1919,33 @@ ...@@ -1919,6 +1919,33 @@
return ScriptsContainer; return ScriptsContainer;
}()); }());
var _a;
var eventsConfig = (_a = {},
_a[MouseEvent.CLICK] = 'click',
_a);
function applyEvents(ctor) {
ctor.prototype.applyEvents = function () {
var events = this.events = new Events();
for (var k in eventsConfig) {
this.addEventListener(k, events.onEvent, events);
}
};
}
var Events = (function (_super) {
__extends(Events, _super);
function Events() {
return _super.call(this) || this;
}
Events.prototype.invoke = function (name, e) {
};
Events.prototype.onEvent = function (e) {
console.log(this.instanceId, e.type, e.currentTarget.name);
};
Events.prototype.destroy = function () {
};
return Events;
}(HashObject));
var Container = (function (_super) { var Container = (function (_super) {
__extends(Container, _super); __extends(Container, _super);
function Container() { function Container() {
...@@ -1928,6 +1955,7 @@ ...@@ -1928,6 +1955,7 @@
_this.children = []; _this.children = [];
_this.applyAutoAdjust(); _this.applyAutoAdjust();
_this.applyScripts(); _this.applyScripts();
_this.applyEvents();
return _this; return _this;
} }
Container_1 = Container; Container_1 = Container;
...@@ -1935,6 +1963,8 @@ ...@@ -1935,6 +1963,8 @@
}; };
Container.prototype.applyScripts = function () { Container.prototype.applyScripts = function () {
}; };
Container.prototype.applyEvents = function () {
};
Container.prototype.onChildrenChange = function (index) { Container.prototype.onChildrenChange = function (index) {
}; };
Container.prototype.addChild = function (child) { Container.prototype.addChild = function (child) {
...@@ -2159,7 +2189,7 @@ ...@@ -2159,7 +2189,7 @@
if (isMouseEvent === void 0) { isMouseEvent = false; } if (isMouseEvent === void 0) { isMouseEvent = false; }
if (!this.visible) if (!this.visible)
return null; return null;
if (isMouseEvent && !this.mouseEnable) if (isMouseEvent && !this.mouseEnabled)
return null; return null;
var children = this.children; var children = this.children;
var length = children.length; var length = children.length;
...@@ -2303,7 +2333,8 @@ ...@@ -2303,7 +2333,8 @@
var Container_1; var Container_1;
Container = Container_1 = __decorate([ Container = Container_1 = __decorate([
applyAutoAdjust, applyAutoAdjust,
applyScript applyScript,
applyEvents
], Container); ], Container);
return Container; return Container;
}(DisplayObject)); }(DisplayObject));
...@@ -4081,7 +4112,7 @@ ...@@ -4081,7 +4112,7 @@
if (isMouseEvent === void 0) { isMouseEvent = false; } if (isMouseEvent === void 0) { isMouseEvent = false; }
if (!this.visible) if (!this.visible)
return null; return null;
if (isMouseEvent && !this.mouseEnable) if (isMouseEvent && !this.mouseEnabled)
return null; return null;
var hitDisplayObject; var hitDisplayObject;
hitDisplayObject = _super.prototype.hitTestPoint.call(this, globalPoint, isMouseEvent); hitDisplayObject = _super.prototype.hitTestPoint.call(this, globalPoint, isMouseEvent);
...@@ -8495,7 +8526,7 @@ ...@@ -8495,7 +8526,7 @@
var s = this; var s = this;
if (!s.visible) if (!s.visible)
return null; return null;
if (isMouseEvent && !s.mouseEnable) if (isMouseEvent && !s.mouseEnabled)
return null; return null;
var hitDisplayObject; var hitDisplayObject;
hitDisplayObject = _super.prototype.hitTestPoint.call(this, point, isMouseEvent); hitDisplayObject = _super.prototype.hitTestPoint.call(this, point, isMouseEvent);
...@@ -9151,7 +9182,7 @@ ...@@ -9151,7 +9182,7 @@
var s = this; var s = this;
if (!s.visible) if (!s.visible)
return null; return null;
if (isMouseEvent && !s.mouseEnable) if (isMouseEvent && !s.mouseEnabled)
return null; return null;
var hitResult = _super.prototype.hitTestPoint.call(this, globalPoint, isMouseEvent); var hitResult = _super.prototype.hitTestPoint.call(this, globalPoint, isMouseEvent);
if (!hitResult) if (!hitResult)
...@@ -10629,6 +10660,7 @@ ...@@ -10629,6 +10660,7 @@
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this['percentWidth'] = 100; _this['percentWidth'] = 100;
_this['percentHeight'] = 100; _this['percentHeight'] = 100;
_this.mouseEnabled = false;
return _this; return _this;
} }
StackContainer.prototype.push = function (view) { StackContainer.prototype.push = function (view) {
...@@ -10698,6 +10730,9 @@ ...@@ -10698,6 +10730,9 @@
function getAssetByUUID(uuid) { function getAssetByUUID(uuid) {
return assetsConfig.find(function (item) { return item.uuid === uuid; }); return assetsConfig.find(function (item) { return item.uuid === uuid; });
} }
function getAssetByName(name) {
return assetsConfig.find(function (item) { return item.name === name; });
}
function fieldChanged(onModify) { function fieldChanged(onModify) {
return function (target, key) { return function (target, key) {
...@@ -10843,7 +10878,8 @@ ...@@ -10843,7 +10878,8 @@
} }
return result; return result;
}; };
DataCenter.prototype.mutate = function (name, data, path) { DataCenter.prototype.mutate = function (name, data, path, dispatch) {
if (dispatch === void 0) { dispatch = true; }
var group = this.getGroup(name); var group = this.getGroup(name);
if (!group) { if (!group) {
return; return;
...@@ -10862,14 +10898,16 @@ ...@@ -10862,14 +10898,16 @@
this.registerGroup(name, data); this.registerGroup(name, data);
} }
} }
for (var _i = 0, _a = this.watchers; _i < _a.length; _i++) { if (dispatch) {
var watcher = _a[_i]; for (var _i = 0, _a = this.watchers; _i < _a.length; _i++) {
if (watcher.path.indexOf(name) === 0) { var watcher = _a[_i];
this.dispatchEvent(watcher.name, { if (watcher.path.indexOf(name) === 0) {
name: watcher.name, this.dispatchEvent(watcher.name, {
path: watcher.path, name: watcher.name,
data: this.getDataByPath(watcher.path), path: watcher.path,
}); data: this.getDataByPath(watcher.path),
});
}
} }
} }
}; };
...@@ -10915,10 +10953,18 @@ ...@@ -10915,10 +10953,18 @@
}); });
Image.prototype.updateSource = function () { Image.prototype.updateSource = function () {
var url = this._source; var url = this._source;
if (this._source.indexOf(assetScheme) === 0) { if (url.indexOf('://') >= 0) {
var uuid = this._source.replace(assetScheme, ''); if (url.indexOf(assetScheme) === 0) {
var assetConfig = getAssetByUUID(uuid); var uuid = url.replace(assetScheme, '');
url = assetConfig.url; var assetConfig = getAssetByUUID(uuid);
url = assetConfig.url;
}
}
else {
var assetConfig = getAssetByName(url);
if (assetConfig) {
url = assetConfig.url;
}
} }
this.texture = Texture.fromImage(url); this.texture = Texture.fromImage(url);
}; };
...@@ -11062,12 +11108,16 @@ ...@@ -11062,12 +11108,16 @@
__extends(GameStage, _super); __extends(GameStage, _super);
function GameStage(stage) { function GameStage(stage) {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.name = 'game-stage';
_this._stage = stage; _this._stage = stage;
_this._dataCenter = dataCenter; _this._dataCenter = dataCenter;
_this['percentWidth'] = 100; _this['percentWidth'] = 100;
_this['percentHeight'] = 100; _this['percentHeight'] = 100;
_this.mouseEnabled = false;
_this.addChild(_this._sceneContainer = new StackContainer()); _this.addChild(_this._sceneContainer = new StackContainer());
_this.addChild(_this._popupContainer = new StackContainer()); _this.addChild(_this._popupContainer = new StackContainer());
_this._sceneContainer.name = 'scene-container';
_this._popupContainer.name = 'popup-container';
return _this; return _this;
} }
Object.defineProperty(GameStage.prototype, "sceneContainer", { Object.defineProperty(GameStage.prototype, "sceneContainer", {
...@@ -11171,9 +11221,11 @@ ...@@ -11171,9 +11221,11 @@
exports.URL_FILE_EXTENSION = URL_FILE_EXTENSION; exports.URL_FILE_EXTENSION = URL_FILE_EXTENSION;
exports.VERSION = VERSION; exports.VERSION = VERSION;
exports.applyAutoAdjust = applyAutoAdjust; exports.applyAutoAdjust = applyAutoAdjust;
exports.applyEvents = applyEvents;
exports.applyScript = applyScript; exports.applyScript = applyScript;
exports.cos = cos; exports.cos = cos;
exports.devicePixelRatio = devicePixelRatio; exports.devicePixelRatio = devicePixelRatio;
exports.getAssetByName = getAssetByName;
exports.getAssetByUUID = getAssetByUUID; exports.getAssetByUUID = getAssetByUUID;
exports.getTexture = getTexture; exports.getTexture = getTexture;
exports.inputFeildIosEnable = inputFeildIosEnable; exports.inputFeildIosEnable = inputFeildIosEnable;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -8,7 +8,7 @@ engine.registerScriptDef(ScriptDemo); ...@@ -8,7 +8,7 @@ engine.registerScriptDef(ScriptDemo);
const gameStage = engine.launch(data); const gameStage = engine.launch(data);
const dataCenter = gameStage.dataCenter; /*const dataCenter = gameStage.dataCenter;
dataCenter.registerGroup('test', { dataCenter.registerGroup('test', {
hello: { hello: {
...@@ -16,15 +16,16 @@ dataCenter.registerGroup('test', { ...@@ -16,15 +16,16 @@ dataCenter.registerGroup('test', {
name: 'tom', name: 'tom',
id: 1001, id: 1001,
age: 29, age: 29,
avatar: '0a5f2064-f5b4-41a9-8a54-2085e208d20f', avatar: 'face',
} }
} }
}); });
/*console.log(dataCenter.getDataByPath('test.hello.aaa.name'));*/ /!*console.log(dataCenter.getDataByPath('test.hello.aaa.name'));*!/
let i = 0; let i = 0;
setInterval(()=>{ setInterval(()=>{
//dataCenter.mutate('test', 'jerry' + Math.random(), 'hello.aaa.name'); let asset = data.assets[i % data.assets.length];
dataCenter.mutate('test', data.assets[i % data.assets.length].uuid, 'hello.aaa.avatar'); dataCenter.mutate('test', asset.name, 'hello.aaa.name');
dataCenter.mutate('test', asset.name, 'hello.aaa.avatar');
i++; i++;
}, 1000); }, 1000);*/
...@@ -19,40 +19,81 @@ const data = { ...@@ -19,40 +19,81 @@ const data = {
properties: { properties: {
width: '100%', width: '100%',
height: '100%', height: '100%',
//mouseEnabled: false,
}, },
uuid: '3a357816-5581-41ba-aa6f-4a6cc40ae396', uuid: '3a357816-5581-41ba-aa6f-4a6cc40ae396',
children: [ children: [
/*{ {
name: "bg", name: "bg",
type: "rect", type: "rect",
uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a", uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a",
//mouseEnabled: false,
properties: { properties: {
width: '100%', width: '100%',
height: '100%', height: '100%',
fillColor: "#1E2127", fillColor: "#1E2127",
}, },
},*/ },
/*{ {
name: "label", name: "button",
type: "label", type: "node",
uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a", uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a",
properties: { properties: {
width: '100%', width: 150,
height: '100%', height: 50,
fillColor: "#44ff00", x: 10,
text: 'Hello ${nickname}', y: 10,
size: 30, mouseChildren: false,
}, },
},*/ children: [
{ {
name: "bg",
type: "rect",
uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a",
properties: {
width: '100%',
height: '100%',
borderRadius: 10,
fillColor: "#27ADB8",
},
},
{
name: "label",
type: "label",
uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a",
properties: {
width: '100%',
height: '100%',
fillColor: "white",
text: 'Button',
size: 30,
textAlign: 'center',
verticalAlign: 'middle',
},
},
],
events: {
click: {
once: false,
behaviors: [
{
uuid: 'aa1',
alias: '主过程',
meta: 'main',
}
]
}
},
},
/*{
name: "img", name: "img",
type: "image", type: "image",
uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a", uuid: "f97bbf76-6923-4669-b5a3-e6382753e49a",
properties: { properties: {
source: 'asset://${avatar}' y: 40,
source: '${avatar}'
}, },
/*scripts: [ scripts: [
{ {
script: 'ScriptDemo', script: 'ScriptDemo',
disabled: false, disabled: false,
...@@ -60,8 +101,8 @@ const data = { ...@@ -60,8 +101,8 @@ const data = {
duration: 1000, duration: 1000,
}, },
} }
]*/ ]
}, },*/
] ]
}, },
{ {
......
...@@ -4,8 +4,10 @@ import { Point } from '../math'; ...@@ -4,8 +4,10 @@ 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';
import {applyAutoAdjust} from "../../zeroing/auto-adjust";
import {applyScript} from "../../zeroing/script-manager"; import {applyAutoAdjust} from "../../zeroing/decorators/auto-adjust";
import {applyScript} from "../../zeroing/decorators/scripts";
import {applyEvents} from "../../zeroing/decorators/events";
/** /**
* 容器类 * 容器类
...@@ -14,6 +16,7 @@ import {applyScript} from "../../zeroing/script-manager"; ...@@ -14,6 +16,7 @@ import {applyScript} from "../../zeroing/script-manager";
*/ */
@applyAutoAdjust @applyAutoAdjust
@applyScript @applyScript
@applyEvents
export default class Container extends DisplayObject { export default class Container extends DisplayObject {
/** /**
...@@ -39,6 +42,7 @@ export default class Container extends DisplayObject { ...@@ -39,6 +42,7 @@ export default class Container extends DisplayObject {
this.children = []; this.children = [];
this.applyAutoAdjust(); this.applyAutoAdjust();
this.applyScripts(); this.applyScripts();
this.applyEvents();
} }
applyAutoAdjust() { applyAutoAdjust() {
...@@ -49,6 +53,10 @@ export default class Container extends DisplayObject { ...@@ -49,6 +53,10 @@ export default class Container extends DisplayObject {
} }
applyEvents() {
}
/** /**
* children改变时 * children改变时
* @private * @private
...@@ -375,7 +383,7 @@ export default class Container extends DisplayObject { ...@@ -375,7 +383,7 @@ export default class Container extends DisplayObject {
hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) { hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) {
if (!this.visible) return null if (!this.visible) return null
//如果禁止子级的鼠标事件 //如果禁止子级的鼠标事件
if (isMouseEvent && !this.mouseEnable) return null; if (isMouseEvent && !this.mouseEnabled) return null;
var children = this.children; var children = this.children;
var length = children.length var length = children.length
let child, hitDisplayObject; let child, hitDisplayObject;
......
...@@ -37,12 +37,12 @@ export class DisplayObject extends EventDispatcher { ...@@ -37,12 +37,12 @@ export class DisplayObject extends EventDispatcher {
/** /**
* 舞台 * 舞台
*/ */
stage: any stage: any;
/** /**
* 名字,预留 * 名字,预留
*/ */
name: string name: string;
/** /**
* 全局透明度 * 全局透明度
...@@ -56,7 +56,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -56,7 +56,7 @@ export class DisplayObject extends EventDispatcher {
/** /**
* 用于计算世界bounds,包括自身和子级,一般只在获取宽高时使用,变形后的 * 用于计算世界bounds,包括自身和子级,一般只在获取宽高时使用,变形后的
*/ */
protected _bounds: Rectangle protected _bounds: Rectangle;
protected _boundsID: number; protected _boundsID: number;
protected _lastBoundsID: number; protected _lastBoundsID: number;
/** /**
...@@ -81,7 +81,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -81,7 +81,7 @@ export class DisplayObject extends EventDispatcher {
/** /**
* 是否可响应鼠标事件 * 是否可响应鼠标事件
*/ */
mouseEnable: boolean = true; mouseEnabled: boolean = true;
/** /**
* 临时父级,特殊用处 * 临时父级,特殊用处
...@@ -158,7 +158,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -158,7 +158,7 @@ export class DisplayObject extends EventDispatcher {
public static _p3: Point = new Point(); public static _p3: Point = new Point();
public static _p4: Point = new Point(); public static _p4: Point = new Point();
//bounds缓存 //bounds缓存
public static temBounds = new Rectangle() public static temBounds = new Rectangle();
/** /**
* 点击碰撞测试,就是舞台上的一个point是否在显示对象内,在则返回该对象,不在则返回null * 点击碰撞测试,就是舞台上的一个point是否在显示对象内,在则返回该对象,不在则返回null
* 对于那些不是继承container,而直接继承displayObject的不用重写,如Bitmap * 对于那些不是继承container,而直接继承displayObject的不用重写,如Bitmap
...@@ -172,7 +172,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -172,7 +172,7 @@ export class DisplayObject extends EventDispatcher {
public hitTestPoint(point: Point, isMouseEvent: boolean = false): DisplayObject { public hitTestPoint(point: Point, isMouseEvent: boolean = false): DisplayObject {
let s = this; let s = this;
if (!s.visible) return null; if (!s.visible) return null;
if (isMouseEvent && !s.mouseEnable) return null; if (isMouseEvent && !s.mouseEnabled) return null;
if (!isMouseEvent) { if (!isMouseEvent) {
//如果不是系统调用则不考虑这个点是从全局来的,只认为这个点就是当前要碰撞测试同级别下的坐标点 //如果不是系统调用则不考虑这个点是从全局来的,只认为这个点就是当前要碰撞测试同级别下的坐标点
if (s._localBoundsSelf.isPointIn(point)) { if (s._localBoundsSelf.isPointIn(point)) {
...@@ -260,6 +260,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -260,6 +260,7 @@ export class DisplayObject extends EventDispatcher {
* @since 1.0.0 * @since 1.0.0
* @public * @public
* @param {Point} point * @param {Point} point
* @param bp
* @return {Point} * @return {Point}
*/ */
public globalToLocal(point: Point, bp: Point = null): Point { public globalToLocal(point: Point, bp: Point = null): Point {
...@@ -272,6 +273,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -272,6 +273,7 @@ export class DisplayObject extends EventDispatcher {
* @public * @public
* @since 1.0.0 * @since 1.0.0
* @param {Point} point * @param {Point} point
* @param bp
* @return {Point} * @return {Point}
*/ */
public localToGlobal(point: Point, bp: Point = null): Point { public localToGlobal(point: Point, bp: Point = null): Point {
...@@ -382,7 +384,7 @@ export class DisplayObject extends EventDispatcher { ...@@ -382,7 +384,7 @@ export class DisplayObject extends EventDispatcher {
this._bounds = null; this._bounds = null;
this.tempDisplayObjectParent = null; this.tempDisplayObjectParent = null;
this._mask = null; this._mask = null;
this.mouseEnable = false; this.mouseEnabled = false;
//标记为已销毁 //标记为已销毁
this.destroyed = true; this.destroyed = true;
} }
......
...@@ -336,7 +336,7 @@ export default class Sprite extends Container { ...@@ -336,7 +336,7 @@ export default class Sprite extends Container {
hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) { hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false) {
if (!this.visible) return null if (!this.visible) return null
//如果禁止子级的鼠标事件 //如果禁止子级的鼠标事件
if (isMouseEvent && !this.mouseEnable) return null; if (isMouseEvent && !this.mouseEnabled) return null;
//如果以后加缓存成位图,另写 //如果以后加缓存成位图,另写
let hitDisplayObject; let hitDisplayObject;
//先检查子级,因为子级层级更高 //先检查子级,因为子级层级更高
......
...@@ -1132,7 +1132,7 @@ export default class Graphics extends Container { ...@@ -1132,7 +1132,7 @@ export default class Graphics extends Container {
hitTestPoint(point: Point, isMouseEvent: boolean = false): DisplayObject { hitTestPoint(point: Point, isMouseEvent: boolean = false): DisplayObject {
let s = this; let s = this;
if (!s.visible) return null; if (!s.visible) return null;
if (isMouseEvent && !s.mouseEnable) return null; if (isMouseEvent && !s.mouseEnabled) return null;
let hitDisplayObject; let hitDisplayObject;
//先检查子级,因为子级层级更高 //先检查子级,因为子级层级更高
......
...@@ -739,7 +739,7 @@ export class Shape extends Sprite { ...@@ -739,7 +739,7 @@ export class Shape extends Sprite {
public hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false): DisplayObject { public hitTestPoint(globalPoint: Point, isMouseEvent: boolean = false): DisplayObject {
let s: Shape = this; let s: Shape = this;
if (!s.visible) return null; if (!s.visible) return null;
if (isMouseEvent && !s.mouseEnable) return null; if (isMouseEvent && !s.mouseEnabled) return null;
//直接继承 //直接继承
var hitResult = super.hitTestPoint(globalPoint, isMouseEvent) var hitResult = super.hitTestPoint(globalPoint, isMouseEvent)
//如果这样返回都没有,直接返回null //如果这样返回都没有,直接返回null
......
...@@ -22,14 +22,20 @@ export class GameStage extends Container { ...@@ -22,14 +22,20 @@ export class GameStage extends Container {
constructor(stage: Stage) { constructor(stage: Stage) {
super(); super();
this.name = 'game-stage';
this._stage = stage; this._stage = stage;
this._dataCenter = dataCenter; this._dataCenter = dataCenter;
this['percentWidth'] = 100; this['percentWidth'] = 100;
this['percentHeight'] = 100; this['percentHeight'] = 100;
this.mouseEnabled = false;
this.addChild(this._sceneContainer = new StackContainer()); this.addChild(this._sceneContainer = new StackContainer());
this.addChild(this._popupContainer = new StackContainer()); this.addChild(this._popupContainer = new StackContainer());
this._sceneContainer.name = 'scene-container';
this._popupContainer.name = 'popup-container';
} }
/** /**
......
...@@ -13,6 +13,7 @@ export class StackContainer extends Container { ...@@ -13,6 +13,7 @@ export class StackContainer extends Container {
this['percentWidth'] = 100; this['percentWidth'] = 100;
this['percentHeight'] = 100; this['percentHeight'] = 100;
this.mouseEnabled = false;
} }
/** /**
......
...@@ -62,3 +62,11 @@ export function loadAssets(config, onProgress?, onComplete?) { ...@@ -62,3 +62,11 @@ export function loadAssets(config, onProgress?, onComplete?) {
export function getAssetByUUID(uuid) { export function getAssetByUUID(uuid) {
return assetsConfig.find(item => item.uuid === uuid); return assetsConfig.find(item => item.uuid === uuid);
} }
/**
* 根据name获取素材配置
* @param name
*/
export function getAssetByName(name) {
return assetsConfig.find(item => item.name === name);
}
...@@ -82,8 +82,9 @@ export class DataCenter extends EventDispatcher { ...@@ -82,8 +82,9 @@ export class DataCenter extends EventDispatcher {
* @param name * @param name
* @param data * @param data
* @param path * @param path
* @param dispatch
*/ */
mutate(name, data?, path?) { mutate(name, data?, path?, dispatch = true) {
let group = this.getGroup(name); let group = this.getGroup(name);
if (!group) { if (!group) {
...@@ -102,13 +103,15 @@ export class DataCenter extends EventDispatcher { ...@@ -102,13 +103,15 @@ export class DataCenter extends EventDispatcher {
} }
} }
for (let watcher of this.watchers) { if(dispatch){
if (watcher.path.indexOf(name) === 0) { for (let watcher of this.watchers) {
this.dispatchEvent(watcher.name, { if (watcher.path.indexOf(name) === 0) {
name: watcher.name, this.dispatchEvent(watcher.name, {
path: watcher.path, name: watcher.name,
data: this.getDataByPath(watcher.path), path: watcher.path,
}); data: this.getDataByPath(watcher.path),
});
}
} }
} }
} }
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* 自适应功能 * 自适应功能
*/ */
import {Event} from "../2d/events"; import {Event} from "../../2d/events";
/** /**
* 自适应数据 * 自适应数据
......
/**
* Created by rockyl on 2019-11-08.
*/
import {Event, MouseEvent} from "../../2d/events";
import {HashObject} from "../../2d/HashObject";
const eventsConfig = {
//[Event.ADDED_TO_STAGE]: 'awake',
//[Event.REMOVED_FROM_STAGE]: 'sleep',
[MouseEvent.CLICK]: 'click',
//[MouseEvent.MOUSE_DOWN]: 'touchstart',
//[MouseEvent.MOUSE_MOVE]: 'touchmove',
//[MouseEvent.MOUSE_UP]: 'touchend',
};
/**
* 应用事件委托
* @param ctor
*/
export function applyEvents(ctor: Function) {
ctor.prototype.applyEvents = function () {
let events = this.events = new Events();
for(let k in eventsConfig){
this.addEventListener(k, events.onEvent, events);
}
};
}
class Events extends HashObject{
constructor(){
super();
}
invoke(name, e) {
}
onEvent(e){
console.log(this.instanceId, e.type, e.currentTarget.name);
//this.events.invoke('awake');
}
destroy(): void {
}
}
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
* *
* 脚本功能 * 脚本功能
*/ */
import {Container} from "../2d/display"; import {Container} from "../../2d/display";
import {Event} from "../2d/events"; import {Event} from "../../2d/events";
const scriptDefs = {}; const scriptDefs = {};
......
...@@ -6,7 +6,8 @@ export * from './GameStage' ...@@ -6,7 +6,8 @@ export * from './GameStage'
export * from './StackContainer' export * from './StackContainer'
export * from './nodes' export * from './nodes'
export * from './assets-manager' export * from './assets-manager'
export * from './auto-adjust'
export * from './script-manager'
export * from './view-interpreter' export * from './view-interpreter'
export * from './launcher' export * from './launcher'
export * from './decorators/auto-adjust'
export * from './decorators/scripts'
export * from './decorators/events'
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
import {Stage} from "../2d/display"; import {Stage} from "../2d/display";
import {GameStage, RENDERER_TYPE, StageScaleMode} from ".."; import {GameStage, Rect, RENDERER_TYPE, StageScaleMode} from "..";
export function launch(config, onAssetsProgress, onAssetsComplete) { export function launch(config, onAssetsProgress, onAssetsComplete) {
const {containerID, designWidth, designHeight, frameRate, scaleMode, rendererType,} = config.launchOptions; const {containerID, designWidth, designHeight, frameRate, scaleMode, rendererType,} = config.launchOptions;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
*/ */
import {Sprite} from "../../2d/display"; import {Sprite} from "../../2d/display";
import Texture from "../../2d/texture/Texture"; import Texture from "../../2d/texture/Texture";
import {getAssetByUUID} from "../assets-manager"; import {getAssetByName, getAssetByUUID} from "../assets-manager";
import {dataCenter} from "../data-center"; import {dataCenter} from "../data-center";
import {ESCAPE_REG_EXP} from "../utils"; import {ESCAPE_REG_EXP} from "../utils";
...@@ -28,10 +28,17 @@ export class Image extends Sprite { ...@@ -28,10 +28,17 @@ export class Image extends Sprite {
private updateSource() { private updateSource() {
let url = this._source; let url = this._source;
if (this._source.indexOf(assetScheme) === 0) { if(url.indexOf('://') >= 0){ //如果是有协议的地址
let uuid = this._source.replace(assetScheme, ''); if (url.indexOf(assetScheme) === 0) {
const assetConfig = getAssetByUUID(uuid); let uuid = url.replace(assetScheme, '');
url = assetConfig.url; const assetConfig = getAssetByUUID(uuid);
url = assetConfig.url;
}
} else{ //否则就使用素材名
const assetConfig = getAssetByName(url);
if(assetConfig){
url = assetConfig.url;
}
} }
this.texture = Texture.fromImage(url); this.texture = Texture.fromImage(url);
} }
......
...@@ -7,7 +7,8 @@ export default class Container extends DisplayObject { ...@@ -7,7 +7,8 @@ export default class Container extends DisplayObject {
children: any[]; children: any[];
containerUpdateTransform: any; containerUpdateTransform: any;
constructor(); constructor();
afterConstructor(): void; applyAutoAdjust(): void;
applyScripts(): void;
onChildrenChange(index: any): void; onChildrenChange(index: any): void;
addChild(child: DisplayObject): DisplayObject; addChild(child: DisplayObject): DisplayObject;
addChildAt(child: DisplayObject, index: number): DisplayObject; addChildAt(child: DisplayObject, index: number): DisplayObject;
......
...@@ -50,16 +50,16 @@ export declare class DisplayObject extends EventDispatcher { ...@@ -50,16 +50,16 @@ export declare class DisplayObject extends EventDispatcher {
alpha: number; alpha: number;
x: number; x: number;
y: number; y: number;
readonly worldMatrix: import("../../../../../duibaGame/renderingengine/src/2d/math/Matrix").Matrix; readonly worldMatrix: import("../../../../../../../../Users/rockyl/WorkSpaces/VisualEditor/renderingengine/src/2d/math/Matrix").Matrix;
readonly localMatrix: import("../../../../../duibaGame/renderingengine/src/2d/math/Matrix").Matrix; readonly localMatrix: import("../../../../../../../../Users/rockyl/WorkSpaces/VisualEditor/renderingengine/src/2d/math/Matrix").Matrix;
position: import("../../../../../duibaGame/renderingengine/src/2d/math/ObservablePoint").ObservablePoint; position: import("../../../../../../../../Users/rockyl/WorkSpaces/VisualEditor/renderingengine/src/2d/math/ObservablePoint").ObservablePoint;
scale: import("../../../../../duibaGame/renderingengine/src/2d/math/ObservablePoint").ObservablePoint; scale: import("../../../../../../../../Users/rockyl/WorkSpaces/VisualEditor/renderingengine/src/2d/math/ObservablePoint").ObservablePoint;
scaleX: number; scaleX: number;
scaleY: number; scaleY: number;
anchor: import("../../../../../duibaGame/renderingengine/src/2d/math/ObservablePoint").ObservablePoint; anchor: import("../../../../../../../../Users/rockyl/WorkSpaces/VisualEditor/renderingengine/src/2d/math/ObservablePoint").ObservablePoint;
anchorX: number; anchorX: number;
anchorY: number; anchorY: number;
skew: import("../../../../../duibaGame/renderingengine/src/2d/math/ObservablePoint").ObservablePoint; skew: import("../../../../../../../../Users/rockyl/WorkSpaces/VisualEditor/renderingengine/src/2d/math/ObservablePoint").ObservablePoint;
rotation: number; rotation: number;
readonly worldVisible: boolean; readonly worldVisible: boolean;
mask: Graphics; mask: Graphics;
......
...@@ -7,8 +7,10 @@ export declare class Loader extends EventDispatcher { ...@@ -7,8 +7,10 @@ export declare class Loader extends EventDispatcher {
_req: XMLHttpRequest; _req: XMLHttpRequest;
constructor(); constructor();
loadSheet(callback: Function, url: string): void; loadSheet(callback: Function, url: string): void;
loadRaw(callback: Function, url: string, type: 'text' | 'json'): void;
loadJson(callback: Function, url: string): void; loadJson(callback: Function, url: string): void;
loadTexture(url: string, uuid?: any): void; loadText(callback: Function, url: string): void;
loadTexture(callback: Function, url: string): void;
loadImage(callback: Function, url: string, crossOrigin?: boolean): HTMLImageElement; loadImage(callback: Function, url: string, crossOrigin?: boolean): HTMLImageElement;
loadSvga(callback: (suc: boolean, data: VideoEntity) => void, url: string): void; loadSvga(callback: (suc: boolean, data: VideoEntity) => void, url: string): void;
cache(name: string, data: any): void; cache(name: string, data: any): void;
......
export { IScrollListItem } from "./ScrollList";
export { ScrollList } from "./ScrollList"; export { ScrollList } from "./ScrollList";
export { ScrollPage } from "./ScrollPage"; export { ScrollPage } from "./ScrollPage";
export { Button } from "./Button"; export { Button } from "./Button";
export * from './GameStage'; export * from './GameStage';
export * from './StackContainer'; export * from './StackContainer';
export * from './shapes'; export * from './nodes';
export * from './assets-manager';
export * from './auto-adjust';
export * from './script-manager';
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