Commit 3ef630dd authored by rockyl's avatar rockyl

完善打包逻辑

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