Commit 8bd346c5 authored by rockyl's avatar rockyl

DataInput修复

parent 88b0d47d
......@@ -45,6 +45,7 @@ declare const args: any;
declare const props: any;
declare const target: engine.Container;
declare const global: any;
declare const vm: engine.VM;
declare function next(type: string, payload?: any);
......
......@@ -608,6 +608,10 @@ export class DisplayObject extends EventDispatcher {
* 更新方法,帧循环的监听事件放在这
*/
public update(deltaTime: number) {
//监听的
if (this.hasEventListener(Event.ENTER_FRAME)) {
this.dispatchEvent(Event.ENTER_FRAME, deltaTime);
}
}
}
/**
......
......@@ -92,9 +92,10 @@ export class Process {
let metaConfig = this._meta;
if (metaConfig) {
if (metaConfig.script) {
let func = new Function('args', 'props', 'target', 'global', warpAsyncScript(metaConfig.script));
let func = new Function('args', 'props', 'target', 'global', 'vm', warpAsyncScript(metaConfig.script));
this.updateProps(payload);
result = await func(payload, this._config.props, this._target, this._vm.getGlobalContext());
let globalContext = this._vm.globalContext;
result = await func(payload, this._config.props, this._target, globalContext, this._vm);
}
} else {
console.warn(`process meta [${meta}] not found`)
......@@ -173,7 +174,8 @@ export class Process {
updateProps(args) {
if (this._originProps) {
let props = this._config.props;
for (let key in props) {
let propsConfig = this._meta.props;
for (let key in propsConfig) {
let value = this._originProps[key];
const valueType = typeof value;
if (valueType == 'object') {
......@@ -191,15 +193,20 @@ export class Process {
props[key] = args ? getDataByPath(args, value.value) : undefined;
break;
case 'data-center':
props[key] = dataCenter.getDataByPath(value.value);
let nameValue = dataCenter.getDataByName(value.value);
props[key] = nameValue !== undefined ? nameValue : dataCenter.getDataByPath(value.value);
break;
}
} else if (value && value.indexOf && value.indexOf(nodeScheme) === 0) {
let uuid = value.replace(nodeScheme, '');
if (uuid) {
props[key] = findNodeByUUID(this._vm.getGlobalContext().gameStage, uuid);
props[key] = findNodeByUUID(this._vm.globalContext.gameStage, uuid);
}
}
if(props[key] === undefined && propsConfig[key].hasOwnProperty('default')){
props[key] = propsConfig[key]['default'];
}
}
}
}
......
......@@ -5,10 +5,13 @@
import {Process} from "./Process";
import {arrayFind} from "../utils";
let ID_INK = 0;
export class VM {
_processMetaLibs;
_globalContext;
_target;
_id;
setup(context) {
const {processMetaLibs, globalContext, target} = context;
......@@ -16,6 +19,7 @@ export class VM {
this._processMetaLibs = processMetaLibs;
this._globalContext = globalContext;
this._target = target;
this._id = ID_INK++;
}
async executeProcess(sequence, id, parentProcess, args) {
......@@ -40,7 +44,11 @@ export class VM {
}
}
getGlobalContext(){
get globalContext() {
return this._globalContext;
}
get id() {
return this._id;
}
}
......@@ -38,9 +38,9 @@ export class GameStage extends Container {
let blackLayer = this._blackLayer = new Rect();
this.addChild(this._sceneContainer = new StackContainer(false));
this.addChild(this._sceneContainer = new StackContainer());
this.addChild(blackLayer);
this.addChild(this._popupContainer = new StackContainer());
this.addChild(this._popupContainer = new StackContainer(false));
blackLayer['percentWidth'] = 100;
blackLayer['percentHeight'] = 100;
......
......@@ -52,6 +52,16 @@ export class DataCenter extends EventDispatcher {
return getDataByPath(this.store, path, throwException);
}
/**
* 根据绑定名获取数据
* @param name
* @param throwException
*/
getDataByName(name, throwException?) {
let watcher = this.getWatcher(name);
return getDataByPath(this.store, watcher.path, throwException);
}
/**
* 填充数据
* @param str
......
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