Commit a3945893 authored by wildfirecode's avatar wildfirecode

1

parent f7a4f271
.rpt2_cache/ .rpt2_cache/
\ No newline at end of file node_modules/
\ No newline at end of file
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
* *
* 对话框内容组件 * 对话框内容组件
*/ */
import { Component } from 'scilla/src'; import ScillaComponent from 'components/base/ScillaComponent';
export default class DialogContent extends Component { export default class DialogContent extends ScillaComponent {
setup(data) { setup(data) {
} }
} }
\ No newline at end of file
import { Component } from 'scilla/src';
import ScillaComponent from 'components/base/ScillaComponent';
import { Transform } from 'scilla-components/src'; import { Transform } from 'scilla-components/src';
export default class BallItem extends Component {
export default class BallItem extends ScillaComponent {
speed = 0; speed = 0;
onUpdate() { onUpdate() {
const { entity } = this; const { entity } = this;
......
...@@ -6,9 +6,10 @@ import { Component, Entity, resource, instantiate } from "scilla"; ...@@ -6,9 +6,10 @@ import { Component, Entity, resource, instantiate } from "scilla";
import { alien } from "../navigator/StackNavigator"; import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator"; import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { Transform } from 'scilla-components/src'; import { Transform } from 'scilla-components/src';
import ScillaComponent from 'scilla-components/src/base/ScillaComponent';
const GROUND_Y = 250; //碰到地板时,球的中心点的y const GROUND_Y = 250; //碰到地板时,球的中心点的y
export default class ScenePlay extends Component implements INavigatorViewBase { export default class ScenePlay extends ScillaComponent implements INavigatorViewBase {
BallItemPrefab: resource; BallItemPrefab: resource;
testPrefab: resource; testPrefab: resource;
......
{"ver":"1.0.1","uuid":"d64549e1-a233-4e9f-83fd-225a57a7d5cd","subMetas":{},"type":"script"}
{ {
"_args": [
[
"git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"/Users/wanghongyuan/scilla-kickball"
]
],
"_from": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git", "_from": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"_id": "scilla-components@1.0.0", "_id": "scilla-components@git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git#7dbeb2b004d67c960aa4f52b679d80bb5f4c9110",
"_inBundle": false, "_inBundle": false,
"_integrity": "", "_integrity": "",
"_location": "/scilla-components", "_location": "/scilla-components",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "git", "type": "git",
"raw": "scilla-components@git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git", "raw": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"name": "scilla-components",
"escapedName": "scilla-components",
"rawSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git", "rawSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"saveSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git", "saveSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"fetchSpec": "http://gitlab2.dui88.com/laoqifeng/scilla-components.git", "fetchSpec": "http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
...@@ -19,10 +23,8 @@ ...@@ -19,10 +23,8 @@
"/" "/"
], ],
"_resolved": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git#7dbeb2b004d67c960aa4f52b679d80bb5f4c9110", "_resolved": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git#7dbeb2b004d67c960aa4f52b679d80bb5f4c9110",
"_spec": "scilla-components@git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git", "_spec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"_where": "/Users/wanghongyuan/kickball0417", "_where": "/Users/wanghongyuan/scilla-kickball",
"bundleDependencies": false,
"deprecated": false,
"devDependencies": { "devDependencies": {
"glob": "^7.1.3", "glob": "^7.1.3",
"rollup-plugin-commonjs": "^9.2.2", "rollup-plugin-commonjs": "^9.2.2",
......
...@@ -19,7 +19,7 @@ export default class BounceZoom extends ScillaComponent { ...@@ -19,7 +19,7 @@ export default class BounceZoom extends ScillaComponent {
super.onAwake(); super.onAwake();
this._tween = createTween(this, this.transform, false, this._tween = createTween(this, this.transform, false,
{clazz: Vector2D, fields: ['x', 'y'], autoPlay: false} {fields: ['x', 'y'], autoPlay: false}
) )
.to({scale: this.targetScale.clone()}, this.duration * 0.5) .to({scale: this.targetScale.clone()}, this.duration * 0.5)
.to({scale: originScale.clone()}, this.duration * 0.5) .to({scale: originScale.clone()}, this.duration * 0.5)
......
...@@ -27,10 +27,10 @@ export default class TouchZoom extends InteractComponent { ...@@ -27,10 +27,10 @@ export default class TouchZoom extends InteractComponent {
const scaleFrom = transform.scale.clone(); const scaleFrom = transform.scale.clone();
const scaleTo = transform.scale.clone().add(scaleOffset); const scaleTo = transform.scale.clone().add(scaleOffset);
this._zoomIn = createTween(this, transform, false, {autoPlay: false, clazz: Vector2D, fields: ['x', 'y']}) this._zoomIn = createTween(this, transform, false, {autoPlay: false, fields: ['x', 'y']})
.to({scale: scaleTo}, duration, easeFunc); .to({scale: scaleTo}, duration, easeFunc);
this._zoomOut = createTween(this, transform, false, {autoPlay: false, clazz: Vector2D, fields: ['x', 'y']}) this._zoomOut = createTween(this, transform, false, {autoPlay: false, fields: ['x', 'y']})
.to({scale: scaleFrom}, duration, easeFunc); .to({scale: scaleFrom}, duration, easeFunc);
} }
} }
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
* Created by rockyl on 2019-04-17. * Created by rockyl on 2019-04-17.
*/ */
import {Component} from 'scilla' import { Component } from 'scilla'
import Transform from "./Transform"; import Transform from "./Transform";
export default class ScillaComponent extends Component{ export default class ScillaComponent extends Component {
get transform():Transform { get transform(): Transform {
return this.entity.getComponentByName('components/base/Transform'); return this.entity.getComponentByName('components/base/Transform');
} }
} }
\ No newline at end of file
...@@ -7,6 +7,5 @@ export * from './base'; ...@@ -7,6 +7,5 @@ export * from './base';
export * from './other'; export * from './other';
export * from './renderer'; export * from './renderer';
export * from './ui'; export * from './ui';
export * from './net';
export * from './registerAllComponents' export * from './registerAllComponents'
\ No newline at end of file
...@@ -9,11 +9,11 @@ import ApiComponent from "./ApiComponent"; ...@@ -9,11 +9,11 @@ import ApiComponent from "./ApiComponent";
import {callApi} from "./webService"; import {callApi} from "./webService";
export default class SampleApi extends ApiComponent { export default class SampleApi extends ApiComponent {
ignoreSuccessField: boolean = false;
name: string; name: string;
uri: string; uri: string;
method: string = 'POST'; method: string = 'POST';
params: any = {}; params: any = {};
ignoreSuccessField: boolean = false;
async callApi(name, paramsInput, ...args){ async callApi(name, paramsInput, ...args){
if(this.name == name){ if(this.name == name){
...@@ -36,11 +36,11 @@ export default class SampleApi extends ApiComponent { ...@@ -36,11 +36,11 @@ export default class SampleApi extends ApiComponent {
utils.injectProp(params, paramsInput); utils.injectProp(params, paramsInput);
} }
const {uri, method} = this; const {uri, method, name} = this;
try { try {
const response = await callApi(uri, params, method, 'json', this.ignoreSuccessField); const response = await callApi(name, uri, params, method, 'json', this.ignoreSuccessField);
this.onGotResponse(response); this.onGotResponse(response);
...@@ -50,3 +50,4 @@ export default class SampleApi extends ApiComponent { ...@@ -50,3 +50,4 @@ export default class SampleApi extends ApiComponent {
} }
} }
} }
...@@ -39,10 +39,10 @@ export default class SamplePollingApi extends ApiComponent { ...@@ -39,10 +39,10 @@ export default class SamplePollingApi extends ApiComponent {
utils.injectProp(params, paramsInput); utils.injectProp(params, paramsInput);
} }
const {uri, method} = this; const {uri, method, name} = this;
try { try {
const response = await polling(this.successFunc, uri, params, this.maxTimes, this.delay, method); const response = await polling(name, this.successFunc, uri, params, this.maxTimes, this.delay, method);
this.onGotResponse(response); this.onGotResponse(response);
......
export { default as SampleApi } from './SampleApi'
\ No newline at end of file
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
* 网络组件 * 网络组件
*/ */
import {utils, customConfig} from "scilla"; import {utils, customConfig, dataCenter, dataCenterConfig} from "scilla";
/** /**
* 调用接口 * 调用接口
* @param uri * @param uri
...@@ -12,8 +11,9 @@ import {utils, customConfig} from "scilla"; ...@@ -12,8 +11,9 @@ import {utils, customConfig} from "scilla";
* @param method * @param method
* @param responseType * @param responseType
* @param ignoreSuccessField * @param ignoreSuccessField
* @param name
*/ */
export function callApi(uri: string, params: any = null, method: string = 'post', responseType = 'json', ignoreSuccessField = false): Promise<any> { export function callApi(name: string, uri: string, params: any = null, method: string = 'post', responseType = 'json', ignoreSuccessField = false): Promise<any> {
let ts = Date.now() + Math.floor(Math.random() * 9999999); let ts = Date.now() + Math.floor(Math.random() * 9999999);
let url = uri.indexOf('//') === 0 ? uri : `${uri}?_=${ts}`; let url = uri.indexOf('//') === 0 ? uri : `${uri}?_=${ts}`;
...@@ -48,7 +48,6 @@ export function callApi(uri: string, params: any = null, method: string = 'post' ...@@ -48,7 +48,6 @@ export function callApi(uri: string, params: any = null, method: string = 'post'
const fetchMethod = responseType == 'jsonp' ? window['fetchJsonp'] : fetch; const fetchMethod = responseType == 'jsonp' ? window['fetchJsonp'] : fetch;
url = baseUrl ? baseUrl + url : url url = baseUrl ? baseUrl + url : url
return fetchMethod(url, options) return fetchMethod(url, options)
.then((response) => { .then((response) => {
if (response.type === 'opaque') { if (response.type === 'opaque') {
...@@ -90,10 +89,15 @@ export function callApi(uri: string, params: any = null, method: string = 'post' ...@@ -90,10 +89,15 @@ export function callApi(uri: string, params: any = null, method: string = 'post'
return Promise.reject(); return Promise.reject();
}) })
.then(response => {
dataCenter.set(dataCenterConfig.ajax, name, response.origin)
return response
})
} }
/** /**
* 轮训请求 * 轮训请求
* @param name
* @param successFunc * @param successFunc
* @param maxTimes * @param maxTimes
* @param delay * @param delay
...@@ -102,7 +106,7 @@ export function callApi(uri: string, params: any = null, method: string = 'post' ...@@ -102,7 +106,7 @@ export function callApi(uri: string, params: any = null, method: string = 'post'
* @param method * @param method
* @param responseType * @param responseType
*/ */
export function polling(successFunc, uri, params, maxTimes = 10, delay = 500, method = 'POST', responseType = 'json'): Promise<any> { export function polling(name, successFunc, uri, params, maxTimes = 10, delay = 500, method = 'POST', responseType = 'json'): Promise<any> {
let p = Promise.resolve(); let p = Promise.resolve();
for (let i = 0; i < maxTimes; i++) { for (let i = 0; i < maxTimes; i++) {
...@@ -128,7 +132,7 @@ export function polling(successFunc, uri, params, maxTimes = 10, delay = 500, me ...@@ -128,7 +132,7 @@ export function polling(successFunc, uri, params, maxTimes = 10, delay = 500, me
); );
function func() { function func() {
return callApi(uri, params, method, responseType).then( return callApi(name, uri, params, method, responseType).then(
(data) => { (data) => {
if (successFunc(data)) { if (successFunc(data)) {
lastData = data; lastData = data;
...@@ -144,20 +148,21 @@ export function polling(successFunc, uri, params, maxTimes = 10, delay = 500, me ...@@ -144,20 +148,21 @@ export function polling(successFunc, uri, params, maxTimes = 10, delay = 500, me
/** /**
* 获取token并发送 * 获取token并发送
* @param name
* @param uri * @param uri
* @param params * @param params
* @param method * @param method
* @param responseType * @param responseType
*/ */
export async function getToken(uri: string, params: any, method: string = 'POST', responseType: string = 'json') { export async function getToken(name: string, uri: string, params: any, method: string = 'POST', responseType: string = 'json') {
if (window['getDuibaToken']) { if (window['getDuibaToken']) {
window['getDuibaToken'](async (tokenObj: any) => { window['getDuibaToken'](async (tokenObj: any) => {
params.token = tokenObj.token; params.token = tokenObj.token;
await this.send(uri, params, method, responseType); await callApi(name, uri, params, method, responseType);
}, () => { }, () => {
}); });
} else { } else {
await this.send(uri, params, method, responseType); await callApi(name, uri, params, method, responseType);
} }
} }
......
...@@ -10,12 +10,34 @@ import TouchZoom from './animation/TouchZoom'; ...@@ -10,12 +10,34 @@ import TouchZoom from './animation/TouchZoom';
import Wave from './animation/Wave'; import Wave from './animation/Wave';
import ZoomLoop from './animation/ZoomLoop'; import ZoomLoop from './animation/ZoomLoop';
import InteractComponent from './base/InteractComponent'; import InteractComponent from './base/InteractComponent';
import ScillaComponent from './base/ScillaComponent';
import TouchInterrupt from './base/TouchInterrupt'; import TouchInterrupt from './base/TouchInterrupt';
import Transform from './base/Transform'; import Transform from './base/Transform';
import AjaxElementComponent from './net/api/hdtool/base/AjaxElementComponent';
import DoJoinComponent from './net/api/hdtool/base/DoJoinComponent';
import GetOrderStatusComponent from './net/api/hdtool/base/GetOrderStatusComponent';
import PrizeDetailComponent from './net/api/hdtool/base/PrizeDetailComponent';
import SubCreditsStatusComponent from './net/api/hdtool/base/SubCreditsStatusComponent';
import DatapashComponent from './net/api/hdtool/game/DatapashComponent';
import GetNgameStartStatusComponent from './net/api/hdtool/game/GetNgameStartStatusComponent';
import NgameManySubmitComponent from './net/api/hdtool/game/NgameManySubmitComponent';
import NgameSubmitComponent from './net/api/hdtool/game/NgameSubmitComponent';
import ResurrectionComponent from './net/api/hdtool/game/ResurrectionComponent';
import ResurrectionStatusComponent from './net/api/hdtool/game/ResurrectionStatusComponent';
import GetGameOrderInfoComponent from './net/api/hdtool/preLottery/GetGameOrderInfoComponent';
import GetGameSubmitComponent from './net/api/hdtool/preLottery/GetGameSubmitComponent';
import CheckOutAnswerComponent from './net/api/hdtool/question/CheckOutAnswerComponent';
import GetQuestionComponent from './net/api/hdtool/question/GetQuestionComponent';
import QuestionSubmitComponent from './net/api/hdtool/question/QuestionSubmitComponent';
import AjaxThroughInfoComponent from './net/api/hdtool/throughGame/AjaxThroughInfoComponent';
import ThroughSubmitComponent from './net/api/hdtool/throughGame/ThroughSubmitComponent';
import ApiComponent from './net/ApiComponent';
import SampleApi from './net/SampleApi';
import SamplePollingApi from './net/SamplePollingApi';
import CameraController from './other/CameraController'; import CameraController from './other/CameraController';
import ContentSizeFitter from './other/ContentSizeFitter'; import ContentSizeFitter from './other/ContentSizeFitter';
import RelativeLayout from './other/RelativeLayout';
import FullStageSize from './other/FullStageSize'; import FullStageSize from './other/FullStageSize';
import RelativeLayout from './other/RelativeLayout';
import CircleRenderer from './renderer/CircleRenderer'; import CircleRenderer from './renderer/CircleRenderer';
import FrameAnimationRenderer from './renderer/FrameAnimationRenderer'; import FrameAnimationRenderer from './renderer/FrameAnimationRenderer';
import GraphicRenderer from './renderer/GraphicRenderer'; import GraphicRenderer from './renderer/GraphicRenderer';
...@@ -39,12 +61,34 @@ export function registerAllComponents(){ ...@@ -39,12 +61,34 @@ export function registerAllComponents(){
registerDef('components/animation/Wave', Wave); registerDef('components/animation/Wave', Wave);
registerDef('components/animation/ZoomLoop', ZoomLoop); registerDef('components/animation/ZoomLoop', ZoomLoop);
registerDef('components/base/InteractComponent', InteractComponent); registerDef('components/base/InteractComponent', InteractComponent);
registerDef('components/base/ScillaComponent', ScillaComponent);
registerDef('components/base/TouchInterrupt', TouchInterrupt); registerDef('components/base/TouchInterrupt', TouchInterrupt);
registerDef('components/base/Transform', Transform); registerDef('components/base/Transform', Transform);
registerDef('components/net/api/hdtool/base/AjaxElementComponent', AjaxElementComponent);
registerDef('components/net/api/hdtool/base/DoJoinComponent', DoJoinComponent);
registerDef('components/net/api/hdtool/base/GetOrderStatusComponent', GetOrderStatusComponent);
registerDef('components/net/api/hdtool/base/PrizeDetailComponent', PrizeDetailComponent);
registerDef('components/net/api/hdtool/base/SubCreditsStatusComponent', SubCreditsStatusComponent);
registerDef('components/net/api/hdtool/game/DatapashComponent', DatapashComponent);
registerDef('components/net/api/hdtool/game/GetNgameStartStatusComponent', GetNgameStartStatusComponent);
registerDef('components/net/api/hdtool/game/NgameManySubmitComponent', NgameManySubmitComponent);
registerDef('components/net/api/hdtool/game/NgameSubmitComponent', NgameSubmitComponent);
registerDef('components/net/api/hdtool/game/ResurrectionComponent', ResurrectionComponent);
registerDef('components/net/api/hdtool/game/ResurrectionStatusComponent', ResurrectionStatusComponent);
registerDef('components/net/api/hdtool/preLottery/GetGameOrderInfoComponent', GetGameOrderInfoComponent);
registerDef('components/net/api/hdtool/preLottery/GetGameSubmitComponent', GetGameSubmitComponent);
registerDef('components/net/api/hdtool/question/CheckOutAnswerComponent', CheckOutAnswerComponent);
registerDef('components/net/api/hdtool/question/GetQuestionComponent', GetQuestionComponent);
registerDef('components/net/api/hdtool/question/QuestionSubmitComponent', QuestionSubmitComponent);
registerDef('components/net/api/hdtool/throughGame/AjaxThroughInfoComponent', AjaxThroughInfoComponent);
registerDef('components/net/api/hdtool/throughGame/ThroughSubmitComponent', ThroughSubmitComponent);
registerDef('components/net/ApiComponent', ApiComponent);
registerDef('components/net/SampleApi', SampleApi);
registerDef('components/net/SamplePollingApi', SamplePollingApi);
registerDef('components/other/CameraController', CameraController); registerDef('components/other/CameraController', CameraController);
registerDef('components/other/ContentSizeFitter', ContentSizeFitter); registerDef('components/other/ContentSizeFitter', ContentSizeFitter);
registerDef('components/other/RelativeLayout', RelativeLayout);
registerDef('components/other/FullStageSize', FullStageSize); registerDef('components/other/FullStageSize', FullStageSize);
registerDef('components/other/RelativeLayout', RelativeLayout);
registerDef('components/renderer/CircleRenderer', CircleRenderer); registerDef('components/renderer/CircleRenderer', CircleRenderer);
registerDef('components/renderer/FrameAnimationRenderer', FrameAnimationRenderer); registerDef('components/renderer/FrameAnimationRenderer', FrameAnimationRenderer);
registerDef('components/renderer/GraphicRenderer', GraphicRenderer); registerDef('components/renderer/GraphicRenderer', GraphicRenderer);
......
...@@ -132,7 +132,7 @@ export default class ScrollView extends InteractComponent { ...@@ -132,7 +132,7 @@ export default class ScrollView extends InteractComponent {
const targetPos = createVector2D(tx, ty); const targetPos = createVector2D(tx, ty);
const duration = Math.min(500, Math.max(targetPos.distance(position), 200)); const duration = Math.min(500, Math.max(targetPos.distance(position), 200));
createTween(this, this._contentTransform, true, {clazz: Vector2D, fields: ['x', 'y']}) createTween(this, this._contentTransform, true, {fields: ['x', 'y']})
.to({position: targetPos}, duration, ease.cubicOut); .to({position: targetPos}, duration, ease.cubicOut);
} }
} }
{ {
"_args": [
[
"git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
"/Users/wanghongyuan/scilla-kickball"
]
],
"_from": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git", "_from": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
"_id": "scilla@1.0.1", "_id": "scilla@git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git#b807e097f6e526fa58e88dff09ef162c3bf89b59",
"_inBundle": false, "_inBundle": false,
"_integrity": "", "_integrity": "",
"_location": "/scilla", "_location": "/scilla",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "git", "type": "git",
"raw": "scilla@git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git", "raw": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
"name": "scilla",
"escapedName": "scilla",
"rawSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git", "rawSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
"saveSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git", "saveSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
"fetchSpec": "http://gitlab2.dui88.com/laoqifeng/scilla-core.git", "fetchSpec": "http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
...@@ -19,10 +23,8 @@ ...@@ -19,10 +23,8 @@
"/" "/"
], ],
"_resolved": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git#b807e097f6e526fa58e88dff09ef162c3bf89b59", "_resolved": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git#b807e097f6e526fa58e88dff09ef162c3bf89b59",
"_spec": "scilla@git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git", "_spec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-core.git",
"_where": "/Users/wanghongyuan/kickball0417", "_where": "/Users/wanghongyuan/scilla-kickball",
"bundleDependencies": false,
"deprecated": false,
"description": "## game engine for HTML5", "description": "## game engine for HTML5",
"devDependencies": { "devDependencies": {
"rollup-plugin-commonjs": "^9.2.2", "rollup-plugin-commonjs": "^9.2.2",
......
...@@ -20,7 +20,7 @@ export type raw = any; ...@@ -20,7 +20,7 @@ export type raw = any;
/** /**
* 动态数据 * 动态数据
*/ */
export type dynamic = string; export type dynamic = Function;
/** /**
* 常用框类型 * 常用框类型
......
...@@ -24,6 +24,8 @@ export const engineConfig: any = { ...@@ -24,6 +24,8 @@ export const engineConfig: any = {
*/ */
export const customConfig: any = {}; export const customConfig: any = {};
export const dataCenterConfig: any = {};
let root: Entity; let root: Entity;
let _flush = 0, _currentFlush = 0; let _flush = 0, _currentFlush = 0;
...@@ -37,9 +39,10 @@ let renderContext, interactContext; ...@@ -37,9 +39,10 @@ let renderContext, interactContext;
* @param _engineConfig * @param _engineConfig
* @param _customConfig * @param _customConfig
*/ */
export function setup(_engineConfig?, _customConfig?) { export function setup(_engineConfig?, _customConfig?, _dataCenterConfig?) {
injectProp(engineConfig, _engineConfig); injectProp(engineConfig, _engineConfig);
injectProp(customConfig, _customConfig); injectProp(customConfig, _customConfig);
injectProp(dataCenterConfig, _dataCenterConfig);
const {canvas, designWidth, designHeight, scaleMode, modifyCanvasSize, touchEnabled} = engineConfig; const {canvas, designWidth, designHeight, scaleMode, modifyCanvasSize, touchEnabled} = engineConfig;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import {Entity, Scene, ScillaEvent} from "../core"; import {Entity, Scene, ScillaEvent} from "../core";
import {getRes} from "../assets-manager"; import {getRes} from "../assets-manager";
import {EngineConfig} from "../engine-config"; import {EngineConfig} from "../engine-config";
import {dataCenter} from "../support";
let entityCache = {}; let entityCache = {};
let entityCacheConfig; let entityCacheConfig;
...@@ -323,6 +324,17 @@ function injectBaseType(node, key, propertyOfConfig, pid?: number) { ...@@ -323,6 +324,17 @@ function injectBaseType(node, key, propertyOfConfig, pid?: number) {
if(propertyValue instanceof Promise){ if(propertyValue instanceof Promise){
keyAvatar = 'async_' + keyAvatar; keyAvatar = 'async_' + keyAvatar;
} }
if (typeof propertyValue === 'function') {
Object.defineProperty(node, keyAvatar, {
get() {
return this[`func_${keyAvatar}`]()
},
set(v) {
this[`func_${keyAvatar}`] = v;
}
})
}
node[keyAvatar] = propertyValue; node[keyAvatar] = propertyValue;
} }
...@@ -351,6 +363,9 @@ function getLink(str: string, pid?: number) { ...@@ -351,6 +363,9 @@ function getLink(str: string, pid?: number) {
} else if (str.indexOf('entity|') == 0) { //entity uuid } else if (str.indexOf('entity|') == 0) { //entity uuid
const uuid = transPrefabUUID(str.substr(7), pid); const uuid = transPrefabUUID(str.substr(7), pid);
result = entityCache[uuid]; result = entityCache[uuid];
} else if (str.indexOf('dynamic|') == 0) { //dynamic
const [_, type, expression] = str.split('|')
result = () => dataCenter.parse(type, expression);
} else { } else {
result = str; result = str;
} }
......
/** /**
* Created by rockyl on 2018/11/8. * Created by rockyl on 2018/11/8.
* *
* 补间动画
*/ */
import {Component} from "../core";
import {lerp, lerpObj} from "../tools/math"; import {lerp, lerpObj} from "../tools/math";
import {injectProp} from "../tools/utils"; import {injectProp} from "../tools/utils";
import HashObject from "../core/HashObject"; import HashObject from "../core/HashObject";
...@@ -18,14 +18,13 @@ enum STATUS { ...@@ -18,14 +18,13 @@ enum STATUS {
} }
export interface ITweenPlugin { export interface ITweenPlugin {
//resolveLerp(fromValue, toValue, ratio, allowOutOfBounds):any; resolveLerp(fromValue, toValue, ratio, allowOutOfBounds): any;
} }
export interface TweenOptions { export interface TweenOptions {
loop?: number; loop?: number;
autoPlay?: boolean; autoPlay?: boolean;
initFields?: string[]; initFields?: string[];
clazz?: any;
fields?: string[]; fields?: string[];
} }
...@@ -85,7 +84,6 @@ export class Tween extends HashObject { ...@@ -85,7 +84,6 @@ export class Tween extends HashObject {
startTime; startTime;
plugins: ITweenPlugin[]; plugins: ITweenPlugin[];
clazz;
fields; fields;
autoPlay: boolean; autoPlay: boolean;
...@@ -102,7 +100,6 @@ export class Tween extends HashObject { ...@@ -102,7 +100,6 @@ export class Tween extends HashObject {
this.target = target; this.target = target;
this.loop = options ? options.loop : 0; this.loop = options ? options.loop : 0;
this.autoPlay = options ? (options.hasOwnProperty('autoPlay') ? options.autoPlay : true) : true; this.autoPlay = options ? (options.hasOwnProperty('autoPlay') ? options.autoPlay : true) : true;
this.clazz = options ? options.clazz : null;
this.fields = options ? options.fields : null; this.fields = options ? options.fields : null;
this.plugins = plugins; this.plugins = plugins;
...@@ -112,11 +109,29 @@ export class Tween extends HashObject { ...@@ -112,11 +109,29 @@ export class Tween extends HashObject {
} }
} }
private resolveLerp(fromValue, toValue, ratio) {
let currentValue;
if (this.plugins.length > 0) {
for (let plugin of this.plugins) {
currentValue = plugin.resolveLerp(fromValue, toValue, ratio, true);
}
} else {
if (typeof toValue == 'object') {
let {fields} = this;
currentValue = lerpObj(fromValue, toValue, ratio, fields || Object.keys(toValue), true);
} else {
currentValue = lerp(fromValue, toValue, ratio, true);
}
}
return currentValue;
}
onUpdate = (t) => { onUpdate = (t) => {
this.t = t; this.t = t;
switch (this.status) { switch (this.status) {
case STATUS.DO_TO: case STATUS.DO_TO:
var {target, startTime, fromProps, toProps, duration, ease, clazz, fields} = this; var {target, startTime, fromProps, toProps, duration, ease,} = this;
var passTime = t - startTime; var passTime = t - startTime;
let timeRatio = Math.min(1, passTime / duration); let timeRatio = Math.min(1, passTime / duration);
...@@ -131,16 +146,16 @@ export class Tween extends HashObject { ...@@ -131,16 +146,16 @@ export class Tween extends HashObject {
let currentValue; let currentValue;
if (timeRatio < 1) { if (timeRatio < 1) {
if (typeof toValue == 'object') { currentValue = this.resolveLerp(fromValue, toValue, ratio);
currentValue = lerpObj(fromValue, toValue, ratio, clazz, fields || Object.keys(toValue), true);
} else {
currentValue = lerp(fromValue, toValue, ratio, true);
}
} else { } else {
currentValue = toValue; currentValue = toValue;
} }
target[key] = currentValue; if(typeof currentValue === 'string'){
injectProp(target[key], currentValue);
}else{
target[key] = currentValue;
}
} }
if (timeRatio >= 1) { if (timeRatio >= 1) {
...@@ -209,14 +224,14 @@ export class Tween extends HashObject { ...@@ -209,14 +224,14 @@ export class Tween extends HashObject {
killTweens(this.target); killTweens(this.target);
} }
if(delay > 0){ if (delay > 0) {
setTimeout(this._doPlay, delay, resetLoopCounting) setTimeout(this._doPlay, delay, resetLoopCounting)
}else{ } else {
this._doPlay(resetLoopCounting); this._doPlay(resetLoopCounting);
} }
} }
private _doPlay=(resetLoopCounting)=>{ private _doPlay = (resetLoopCounting) => {
addTween(this.target, this); addTween(this.target, this);
this._start(resetLoopCounting); this._start(resetLoopCounting);
}; };
...@@ -266,7 +281,7 @@ export class Tween extends HashObject { ...@@ -266,7 +281,7 @@ export class Tween extends HashObject {
_start(resetLoopCounting: boolean = true) { _start(resetLoopCounting: boolean = true) {
this.status = STATUS.PENDING; this.status = STATUS.PENDING;
if(resetLoopCounting){ if (resetLoopCounting) {
this.loopCounting = 0; this.loopCounting = 0;
} }
this.host.callOnNextTick(this._readyStart); this.host.callOnNextTick(this._readyStart);
......
...@@ -13,4 +13,5 @@ export {default as Size} from './Size' ...@@ -13,4 +13,5 @@ export {default as Size} from './Size'
export {default as LocalStorage} from './LocalStorage' export {default as LocalStorage} from './LocalStorage'
export {TextStyle} from './TextStyle' export {TextStyle} from './TextStyle'
export {default as EventEmitter} from './EventEmitter'; export {default as EventEmitter} from './EventEmitter';
\ No newline at end of file export {default as dataCenter} from './DataCenter';
\ No newline at end of file
...@@ -34,18 +34,17 @@ export function lerp(begin, end, t, allowOutOfBounds = false) { ...@@ -34,18 +34,17 @@ export function lerp(begin, end, t, allowOutOfBounds = false) {
* @param begin * @param begin
* @param end * @param end
* @param t * @param t
* @param clazz
* @param fields * @param fields
* @param allowOutOfBounds * @param allowOutOfBounds
* @return * @return
*/ */
export function lerpObj(begin, end, t, clazz, fields, allowOutOfBounds = false) { export function lerpObj(begin, end, t, fields, allowOutOfBounds = false) {
const type = typeof begin; const type = typeof begin;
if (type !== typeof end) { if (type !== typeof end) {
console.error('begin and end need same type') console.error('begin and end need same type')
} }
const temp = new clazz(); const temp = {};
for (let field of fields) { for (let field of fields) {
temp[field] = lerp(begin[field], end[field], t, allowOutOfBounds); temp[field] = lerp(begin[field], end[field], t, allowOutOfBounds);
} }
......
{ {
"_from": "tslib@^1.9.3", "_args": [
[
"tslib@1.9.3",
"/Users/wanghongyuan/scilla-kickball"
]
],
"_from": "tslib@1.9.3",
"_id": "tslib@1.9.3", "_id": "tslib@1.9.3",
"_inBundle": false, "_inBundle": false,
"_integrity": "sha1-1+TdeSRdhUKMTX5IIqeZF5VMooY=", "_integrity": "sha1-1+TdeSRdhUKMTX5IIqeZF5VMooY=",
"_location": "/tslib", "_location": "/tslib",
"_phantomChildren": {}, "_phantomChildren": {},
"_requested": { "_requested": {
"type": "range", "type": "version",
"registry": true, "registry": true,
"raw": "tslib@^1.9.3", "raw": "tslib@1.9.3",
"name": "tslib", "name": "tslib",
"escapedName": "tslib", "escapedName": "tslib",
"rawSpec": "^1.9.3", "rawSpec": "1.9.3",
"saveSpec": null, "saveSpec": null,
"fetchSpec": "^1.9.3" "fetchSpec": "1.9.3"
}, },
"_requiredBy": [ "_requiredBy": [
"/" "/"
], ],
"_resolved": "http://registry.npm.taobao.org/tslib/download/tslib-1.9.3.tgz?cache=0&other_urls=http%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-1.9.3.tgz", "_resolved": "http://registry.npm.taobao.org/tslib/download/tslib-1.9.3.tgz?cache=0&other_urls=http%3A%2F%2Fregistry.npm.taobao.org%2Ftslib%2Fdownload%2Ftslib-1.9.3.tgz",
"_shasum": "d7e4dd79245d85428c4d7e4822a79917954ca286", "_spec": "1.9.3",
"_spec": "tslib@^1.9.3", "_where": "/Users/wanghongyuan/scilla-kickball",
"_where": "/Users/wanghongyuan/kickball0417",
"author": { "author": {
"name": "Microsoft Corp." "name": "Microsoft Corp."
}, },
"bugs": { "bugs": {
"url": "https://github.com/Microsoft/TypeScript/issues" "url": "https://github.com/Microsoft/TypeScript/issues"
}, },
"bundleDependencies": false,
"deprecated": false,
"description": "Runtime library for TypeScript helper functions", "description": "Runtime library for TypeScript helper functions",
"homepage": "http://typescriptlang.org/", "homepage": "http://typescriptlang.org/",
"jsnext:main": "tslib.es6.js", "jsnext:main": "tslib.es6.js",
......
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