Commit 3ef630dd authored by rockyl's avatar rockyl

完善打包逻辑

parent 8986c628
......@@ -1915,9 +1915,9 @@
script[k] = options[k];
}
this._scripts.push(script);
script.mounted();
script.mounted && script.mounted();
if (this._host && this._host.stage) {
script.awake();
script.awake && script.awake();
}
return script;
};
......@@ -1925,9 +1925,9 @@
var script = this._scripts.splice(index, 1)[0];
if (script) {
if (this._host && this._host.stage) {
script.sleep();
script.sleep && script.sleep();
}
script.destroy();
script.destroy && script.destroy();
}
return script;
};
......@@ -1945,7 +1945,7 @@
for (var _i = 0, _a = this._scripts; _i < _a.length; _i++) {
var script = _a[_i];
if (!script.disabled) {
script.awake();
script.awake && script.awake();
}
}
};
......@@ -1953,7 +1953,7 @@
for (var _i = 0, _a = this._scripts; _i < _a.length; _i++) {
var script = _a[_i];
if (!script.disabled) {
script.sleep();
script.sleep && script.sleep();
}
}
};
......@@ -1962,7 +1962,7 @@
for (var _i = 0, _a = this._scripts; _i < _a.length; _i++) {
var script = _a[_i];
if (!script.disabled) {
script.update(t);
script.update && script.update(t);
}
}
};
......@@ -2301,6 +2301,7 @@
for (var k in eventsMapping) {
this.addEventListener(k, eventsProxy.onEvent, eventsProxy);
}
eventsProxy.invoke('init', this);
};
}
var EventsProxy = (function (_super) {
......@@ -2308,20 +2309,20 @@
function EventsProxy() {
return _super.call(this) || this;
}
EventsProxy.prototype.invoke = function (name, e) {
EventsProxy.prototype.invoke = function (name, target) {
if (this.eventsConfig) {
var eventConfig = this.eventsConfig[name];
if (eventConfig) {
executeBehavior({
main: eventConfig.behaviors[0],
}, 'main', e.target);
}, 'main', target);
}
}
};
EventsProxy.prototype.onEvent = function (e) {
var eventName = eventsMapping[e.type];
if (eventName) {
this.invoke(eventName, e);
this.invoke(eventName, e.target);
}
};
EventsProxy.prototype.destroy = function () {
......
This diff is collapsed.
......@@ -20,6 +20,7 @@ var Wave = (function () {
Wave.prototype.sleep = function () {
console.log('sleep');
};
Wave.id = 'wave';
return Wave;
}());
exports["default"] = Wave;
......@@ -3,6 +3,7 @@
*/
export default class Wave {
static id = 'wave';
host;
duration;
......
/**
* Created by rockyl on 2019-11-07.
*/
class ZoomButton {
static name = 'ZoomButton';
zoomTo = 1.1;
mounted() {
this.host.anchorX = this.host.width / 2;
this.host.anchorY = this.host.height / 2;
this.host.addEventListener(engine.MouseEvent.MOUSE_DOWN, this._onMouseDown, this);
this.host.addEventListener(engine.MouseEvent.MOUSE_UP, this._onMouseUp, this);
}
_onMouseDown(e) {
this.host.scaleX = this.host.scaleY = this.zoomTo;
}
_onMouseUp(e) {
this.host.scaleX = this.host.scaleY = 1;
}
}
"use strict";
exports.__esModule = true;
var ZoomButton = (function () {
function ZoomButton() {
this.zoomTo = 1.1;
}
ZoomButton.prototype.mounted = function () {
this.host.anchorX = this.host.width / 2;
this.host.anchorY = this.host.height / 2;
this.host.addEventListener(engine.MouseEvent.MOUSE_DOWN, this._onMouseDown, this);
this.host.addEventListener(engine.MouseEvent.MOUSE_UP, this._onMouseUp, this);
};
ZoomButton.prototype._onMouseDown = function (e) {
this.host.scaleX = this.host.scaleY = this.zoomTo;
};
ZoomButton.prototype._onMouseUp = function (e) {
this.host.scaleX = this.host.scaleY = 1;
};
ZoomButton.id = 'zoom-button';
return ZoomButton;
}());
exports["default"] = ZoomButton;
......@@ -3,7 +3,7 @@
*/
const data = {
launchOptions: {
options: {
entrySceneView: 'view1',
containerID: 'game-container',
designWidth: 750,
......@@ -430,15 +430,15 @@ let func = new Function('return '+leftValue+args.operator+rightValue);
let result = func();
resolve({type: result ? 'equal' : 'unequal'});
`,
output: ['complete'],
output: ['equal','unequal'],
},
{
id: 'nestProc',
name: 'NestProc',
metas: {
print: {
id: 'print',
name: 'Print',
id: 'log',
name: 'Log',
props: {
text: {type: 'string', default: ''},
},
......@@ -461,7 +461,7 @@ resolve({type: result ? 'equal' : 'unequal'});
2: {
uuid: '2',
alias: '打印',
meta: 'print',
meta: 'log',
props: {
text: 'hello',
},
......
......@@ -26,6 +26,8 @@ export function applyEvents(ctor: Function) {
for (let k in eventsMapping) {
this.addEventListener(k, eventsProxy.onEvent, eventsProxy);
}
eventsProxy.invoke('init', this);
};
}
......@@ -36,13 +38,13 @@ class EventsProxy extends HashObject {
super();
}
invoke(name, e) {
invoke(name, target) {
if (this.eventsConfig) {
const eventConfig = this.eventsConfig[name];
if (eventConfig) {
executeBehavior({
main: eventConfig.behaviors[0],
}, 'main', e.target);
}, 'main', target);
}
}
}
......@@ -50,7 +52,7 @@ class EventsProxy extends HashObject {
onEvent(e) {
let eventName = eventsMapping[e.type];
if (eventName) {
this.invoke(eventName, e);
this.invoke(eventName, e.target);
}
}
......
......@@ -113,9 +113,9 @@ class ScriptsProxy {
}
this._scripts.push(script);
script.mounted();
script.mounted && script.mounted();
if (this._host && this._host.stage) {
script.awake();
script.awake && script.awake();
}
return script;
......@@ -129,9 +129,9 @@ class ScriptsProxy {
let script = this._scripts.splice(index, 1)[0];
if (script) {
if (this._host && this._host.stage) {
script.sleep();
script.sleep && script.sleep();
}
script.destroy();
script.destroy && script.destroy();
}
return script;
}
......@@ -157,7 +157,7 @@ class ScriptsProxy {
onAddedToStage() {
for (let script of this._scripts) {
if (!script.disabled) {
script.awake();
script.awake && script.awake();
}
}
}
......@@ -168,7 +168,7 @@ class ScriptsProxy {
onRemovedFromStage() {
for (let script of this._scripts) {
if (!script.disabled) {
script.sleep();
script.sleep && script.sleep();
}
}
}
......@@ -180,7 +180,7 @@ class ScriptsProxy {
let t = e.data;
for (let script of this._scripts) {
if (!script.disabled) {
script.update(t);
script.update && script.update(t);
}
}
}
......
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