Commit 7576e313 authored by wildfirecode's avatar wildfirecode

1

parent acea8926
{"ver":"1.0.1","uuid":"d79519a3-915b-4a9f-9303-a15b642cfe24","subMetas":{},"isGroup":true}
This diff is collapsed.
{"ver":"1.0.1","uuid":"1f50815f-bf2f-4cf6-8432-f56f3aa834ef","subMetas":{},"type":"scene"}
{"ver":"1.0.1","uuid":"def65e96-eed7-44b3-9804-e76dea9e5062","subMetas":{},"isGroup":true}
/**
* Created by rockyl on 2019-04-09.
*/
import {createTween, ease, Entity} from "scilla";
export async function playAnimation(config, context){
for(let partName in config){
let partConfig = config[partName];
let part:Entity = context[partName];
for(let componentName in partConfig){
let component = part.getComponent(componentName);
let {params, duration, ease: easeName} = partConfig[componentName];
createTween(context, component)
.to(params, duration, ease[easeName]);
}
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"e8fac37e-73fa-44ec-b2c7-6c42eeed48fd","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"b64ff277-7d22-4207-9f2b-d3f5669feeca","subMetas":{},"isGroup":true}
import { Transform } from 'scilla-components/src';
import DialogContent from "../popup/DialogContent";
export default class RulePanel extends DialogContent {
// Title: Entity;
// Content: Entity;
// ConfirmButton: Entity;
setup(data: any = {}) {
this.entity.getComponent(Transform).alpha = 1;
// const { title = 'Alert', content = '', button = 'Confirm' } = data;
// this.Title.getComponent(TextRenderer).text = title;
// this.Content.getComponent(TextRenderer).text = content;
// this.ConfirmButton.getChildrenByName('Label')[0].getComponent(TextRenderer).text = button;
}
}
{"ver":"1.0.1","uuid":"ba14eec1-ec40-4288-b685-c3e46ee67149","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"db2a042c-d8d8-4bd6-bc1f-60a10c41bdd6","subMetas":{},"isGroup":true}
/**
* Created by rocky.l on 2017/1/19.
*
* 场景导航器
*/
import { alien } from "./StackNavigator";
import NavigatorAction = alien.NavigatorAction;
export interface INavigatorViewBase {
onAddView(): boolean;
onWillMount(last: string, action: NavigatorAction, parameters: any): Promise<any>;
onWillUnMount(next: string, action: NavigatorAction, parameters: any): Promise<any>;
onWillEnter(last: string, action: NavigatorAction, parameters: any): Promise<any>;
onDidEnter(last: string, action: NavigatorAction, parameters: any): void;
onWillLeave(next: string, action: NavigatorAction, parameters: any): Promise<any>;
onDidLeave(next: string, action: NavigatorAction, parameters: any): void;
}
{"ver":"1.0.1","uuid":"ea74b1a5-4d17-4b99-8e60-1e3b5aabf31b","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-04-09.
*
* 单场景导航器
*/
import { Component } from "scilla";
import { ScenePlay, SceneStart } from "../scenes";
import { VirtualNavigator } from "./VirtualNavigator";
export default class SingleSceneNavigator extends Component {
_navigator: VirtualNavigator;
onCreate() {
super.onCreate();
this._navigator = new VirtualNavigator(this.entity);
this._navigator.register('start', 'SceneStart', SceneStart);
this._navigator.register('play', 'ScenePlay', ScenePlay);
}
onAwake() {
super.onAwake();
this.push('start');
}
onUpdate(t) {
super.onUpdate(t);
}
onSleep() {
super.onSleep();
}
onDestroy() {
super.onDestroy();
}
push(name: string, parameters: any = null) {
this._navigator.stack.push(name, parameters);
}
pop(parameters: any = null) {
this._navigator.stack.pop(parameters);
}
popToBottom(parameters: any = null) {
this._navigator.stack.popTo(0, null, parameters);
}
popAll(name: string, parameters: any = null) {
this._navigator.stack.popAll(name, parameters);
}
replace(name: string, parameters: any = null) {
this._navigator.stack.replace(name, parameters);
}
jump(name: string, parameters: any = null) {
this._navigator.stack.jump(name, parameters);
}
}
{"ver":"1.0.1","uuid":"b9511adc-3aea-4f7e-a864-7dd8cd77f1ea","subMetas":{},"type":"script"}
/**
* Created by rocky.l on 2017/1/17.
*
* 堆栈导航器
*/
export module alien {
export enum NavigatorAction {Push, Pop, Replace, Jump}
export interface INavigatorDelegate {
onEnter(name: string, last: string, action: NavigatorAction, parameters: any);
onLeave(name: string, next: string, action: NavigatorAction, parameters: any);
onError(error: Error);
}
export class StackNavigator {
private _stack: string[];
private _delegate: INavigatorDelegate;
constructor(delegate: INavigatorDelegate) {
this._stack = [];
this._delegate = delegate;
}
private catchPromise(p: Promise<any>) {
if (p) {
p.catch((e => {
this._delegate.onError(e);
}))
}
}
push(name: string, parameters: any = null) {
let last: string = this.getTopSceneName();//获取当前的场景名称
if (last) {
if (last == name) {//如果当前场景和切换场景名称相同,那么不进行场景切换
return;
}
//老的场景进行leave
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Push, parameters));
}
this._stack.push(name);
//新的场景进行enter
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Push, parameters));
}
popTo(index, name?: string, parameters: any = null) {
if (this._stack.length > 0 && this._stack.length < (index + 1)) {
return;
}
let last: string = this.getTopSceneName();
this._stack.splice(Math.max(index + 1, 0));
let next: string = this._stack[index];
if (!next) {
this._stack.push(next = name);
}
if (last) {
this.catchPromise(this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters));
}
this.catchPromise(this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters));
}
pop(parameters: any = null) {
this.popTo(this._stack.length - 2, null, parameters);
}
popAll(name: string, parameters: any = null) {
this.popTo(-1, name, parameters);
}
replace(name: string, parameters: any = null) {
let last: string = this._stack.pop();
this._stack.push(name);
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Replace, parameters));
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Replace, parameters));
}
jump(name: string, parameters: any = null){
if(this._stack.length < 2){
this.push(name, parameters);
return;
}
let last:string = this._stack.pop();
this._stack.splice(1);
let next:string = name;
this._stack.push(next);
this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters);
this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters);
}
private getTopSceneName(): string {
return this._stack.length > 0 ? this._stack[this._stack.length - 1] : null;
}
private getBottomSceneName(): string {
return this._stack.length > 0 ? this._stack[0] : null;
}
}
}
{"ver":"1.0.1","uuid":"f5068160-2556-48f9-9e64-05ed06dd74d9","subMetas":{},"type":"script"}
/**
* Created by rocky.l on 2017/1/19.
*
* 场景导航器
*/
import {Entity, EventEmitter} from 'scilla'
import {alien} from "./StackNavigator";
import NavigatorAction = alien.NavigatorAction;
import INavigatorDelegate = alien.INavigatorDelegate;
import StackNavigator = alien.StackNavigator;
const showLog = true;
export const VIEW_WILL_ENTER: string = 'VIEW_WILL_ENTER';
export const VIEW_DID_ENTER: string = 'VIEW_DID_ENTER';
export const VIEW_WILL_LEAVE: string = 'VIEW_WILL_LEAVE';
export const VIEW_DID_LEAVE: string = 'VIEW_DID_LEAVE';
export interface INavigatorViewBase {
onWillMount(last: string, action: NavigatorAction, parameters: any): Promise<any>;
onWillUnMount(next: string, action: NavigatorAction, parameters: any): Promise<any>;
onWillEnter(last: string, action: NavigatorAction, parameters: any): Promise<any>;
onDidEnter(last: string, action: NavigatorAction, parameters: any): void;
onWillLeave(next: string, action: NavigatorAction, parameters: any): Promise<any>;
onDidLeave(next: string, action: NavigatorAction, parameters: any): void;
}
export class VirtualNavigator extends EventEmitter implements INavigatorDelegate {
stack: StackNavigator;
protected _currentName: string;
protected _currentView: INavigatorViewBase;
protected _classDic: any;
protected _container: Entity;
constructor(container) {
super();
this._container = container;
this._classDic = {};
this.stack = new StackNavigator(this);
}
register(alias: string, childName: string, componentDef): void {
this._classDic[alias] = {
childName,
componentDef,
};
}
get currentView(): INavigatorViewBase {
return this._currentView;
}
get currentName(): string {
return this._currentName;
}
protected getViewInstanceByName(name: string): any {
let {childName, componentDef,} = this._classDic[name];
let scene: Entity = this._container.getChildrenByName(childName)[0];
return scene.getComponent(componentDef) ;
}
/**
* 栈入实现
* @param name
* @param last
* @param action
* @param parameters
* @returns {Promise<void>}
*/
async onEnter(name: string, last: string, action: NavigatorAction, parameters: any) {
let view: INavigatorViewBase = this.getViewInstanceByName(name);
this._currentView = view;
this._currentName = name;
if (showLog) console.log(name + ' will mount.');
await view.onWillMount(last, action, parameters);
if (showLog) console.log(name + ' will enter.');
this.emit(VIEW_WILL_ENTER, {name, last, action, parameters});
await view.onWillEnter(last, action, parameters);
if (showLog) console.log(name + ' did enter.');
this.emit(VIEW_DID_ENTER, {name, last, action, parameters});
view.onDidEnter(last, action, parameters);
}
/**
* 栈出实现
* @param name
* @param next
* @param action
* @param parameters
* @returns {Promise<void>}
*/
async onLeave(name: string, next: string, action: NavigatorAction, parameters: any) {
let view: INavigatorViewBase = this.getViewInstanceByName(name);
await view.onWillUnMount(name, action, parameters);
if (showLog) console.log(name + ' will leave.');
this.emit(VIEW_WILL_LEAVE, {name, next, action, parameters});
await view.onWillLeave(next, action, parameters);
if (showLog) console.log(name + ' did leave.');
this.emit(VIEW_DID_LEAVE, {name, next, action, parameters});
view.onDidLeave(next, action, parameters);
}
/**
* 当收到错误实现
* @param error
*/
onError(error: Error) {
}
}
{"ver":"1.0.1","uuid":"aaca9542-45fc-4165-be5d-5f2f916b9238","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"983dc353-e2f8-408e-a725-99f9824dd27e","subMetas":{},"isGroup":true}
/**
* Created by rockyl on 2018-12-12.
*
* 对话框内容组件
*/
import { Component } from 'scilla/src';
export default class DialogContent extends Component {
setup(data) {
}
}
{"ver":"1.0.1","uuid":"2657ed67-fc9d-48b4-9ffa-dc242e49f212","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2018-12-12.
*
* 弹层
*/
import {
ease,
getRenderContext, createTween, Component,
} from "scilla";
import DialogContent from "./DialogContent";
import RectRenderer from "components/renderer/RectRenderer";
import TouchInterrupt from "components/base/TouchInterrupt";
import Transform from "components/base/Transform";
import globalEvent from "globalEvent";
export default class Popup extends Component {
showDuration: number = 300;
hideDuration: number = 200;
private _bgRenderer: RectRenderer;
private _touchInterrupt: TouchInterrupt;
private _stageSize: any;
private _callback;
onAwake() {
super.onAwake();
this._stageSize = getRenderContext().getStageSize();
this._touchInterrupt = this.entity.getComponent(TouchInterrupt);
this._touchInterrupt.enabled = false;
const bgRenderer = this._bgRenderer = this.entity.getComponent(RectRenderer);
bgRenderer.enabled = false;
globalEvent.on('popup', this.onShowAlert, this);
/*setTimeout(() => {
this.showDialog('Alert', {title: 'hello', content: 'fuck you!!!'});
}, 1000);*/
}
onUpdate(t) {
super.onUpdate(t);
}
onSleep() {
super.onSleep();
}
onDestroy() {
super.onDestroy();
}
setBgVisible(visible) {
this._bgRenderer.enabled = visible;
this._touchInterrupt.enabled = visible;
}
setupDialog(dialog, data) {
dialog.enabled = true;
const content: DialogContent = dialog.getComponent(DialogContent);
content.setup(data);
}
showDialog(name, params?, callback?) {
let dialog = this.entity.getChildrenByName(name)[0];
const parent = dialog.parent;
parent.removeChild(dialog);
parent.addChildAt(dialog, parent.children.length);
this._callback = callback;
this.setBgVisible(true);
this.setupDialog(dialog, params);
const transform = dialog.getComponent(Transform);
transform.position.setXY(0, -this._stageSize.height);
createTween(this, transform.position)
.to({ x: 0, y: 0 }, this.showDuration, ease.backOut);
}
hideDialog(name) {
let dialog = this.entity.getChildrenByName(name)[0];
this.setBgVisible(false);
const transform = dialog.getComponent(Transform);
createTween(this, transform.position)
.to({ y: -this._stageSize.height }, this.hideDuration, ease.backIn)
.call(function () {
this._callback && this._callback();
this._callback = null;
}, this);
}
onShowAlert(data, callback) {
const { name,params } = data;
this.showDialog(name, params, callback);
}
}
{"ver":"1.0.1","uuid":"403a3aeb-aa5d-4957-8be4-1ab61fd1b4aa","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"d7c0243c-754a-4082-89b0-5d93cc2f8cae","subMetas":{},"isGroup":true}
/**
* Created by rockyl on 2019-04-09.
*/
import { Component } from "scilla";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { Transform } from 'scilla-components/src';
export default class ScenePlay extends Component implements INavigatorViewBase{
onAwake() {
super.onAwake();
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
(this.entity.getComponent(Transform) as Transform).alpha = 1;
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
(this.entity.getComponent(Transform) as Transform).alpha = 0;
}
async onWillEnter(last: string, action: alien.NavigatorAction, parameters: any) {
}
async onWillLeave(next: string, action: alien.NavigatorAction, parameters: any) {
}
onWillMount(last: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
onWillUnMount(next: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
}
{"ver":"1.0.1","uuid":"511bb8db-5e80-4646-9205-c9fa93f120c3","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-04-09.
*/
import { Component, Entity } from "scilla";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { Transform } from 'scilla-components/src';
import globalEvent from "globalEvent";
export default class SceneStart extends Component implements INavigatorViewBase {
startbtn: Entity;
rankbtn: Entity;
rulebtn: Entity;
onAwake() {
super.onAwake();
}
onClick_startbtn() {
console.log('onClick_startbtn');
globalEvent.emit('popup', { name: 'RulePanel', params: {} }, this.onAlertClose);
}
onAlertClose() {
console.log('onAlertClose');
};
onClick_rankbtn() {
alert('onClick_rankbtn')
// globalEvent.emit('alert', {title: 'Success', content: 'You complete this puzzle', button: 'Next level'}, this.onAlertClose);
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
(this.entity.getComponent(Transform) as Transform).alpha = 1;
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
(this.entity.getComponent(Transform) as Transform).alpha = 0;
}
async onWillEnter(last: string, action: alien.NavigatorAction, parameters: any) {
}
async onWillLeave(next: string, action: alien.NavigatorAction, parameters: any) {
}
onWillMount(last: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
onWillUnMount(next: string, action: alien.NavigatorAction, parameters: any): Promise<any> {
return undefined;
}
}
{"ver":"1.0.1","uuid":"6bd4a810-2792-482e-a03a-5caa2506781c","subMetas":{},"type":"script"}
/**
* Created by rockyl on 2019-04-09.
*/
export {default as SceneStart} from "./SceneStart";
export {default as ScenePlay} from "./ScenePlay";
{"ver":"1.0.1","uuid":"58b64019-1aee-4bb2-81f9-d964e2f1bfaa","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"cdb89785-2908-4cb5-8b14-75d02e37d808","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"e00fab97-a62c-459b-a61b-a9d7a1e10a21","subMetas":{"火-1.png":{"ver":"1.0.1","uuid":"94680781-2b1b-432e-9858-4ff21dd04d0c","rawTextureUuid":"e00fab97-a62c-459b-a61b-a9d7a1e10a21","type":"texture"},"火箭-1.png":{"ver":"1.0.1","uuid":"2f8360c7-b059-4f1e-b651-37a32eb4a247","rawTextureUuid":"e00fab97-a62c-459b-a61b-a9d7a1e10a21","type":"texture"}},"type":"sheet"}
{"ver":"1.0.1","uuid":"8f66fcf4-2eff-4d68-b65c-710ce6e3a4c9","subMetas":{"closeBtn-1.png":{"ver":"1.0.1","uuid":"c9c03b0a-1a91-49f1-b28d-bfeff883ad3c","rawTextureUuid":"8f66fcf4-2eff-4d68-b65c-710ce6e3a4c9","type":"texture"},"游戏说明-1.png":{"ver":"1.0.1","uuid":"1622356e-272a-47d8-866c-bd519f6c9f6c","rawTextureUuid":"8f66fcf4-2eff-4d68-b65c-710ce6e3a4c9","type":"texture"}},"type":"sheet"}
{"ver":"1.0.1","uuid":"065474c4-463f-4abd-9e49-fef8358decee","subMetas":{"btn1.png":{"ver":"1.0.1","uuid":"fc8debf8-e3e5-4b11-b3fa-3eba3fe274e8","rawTextureUuid":"065474c4-463f-4abd-9e49-fef8358decee","type":"texture"},"按钮-2.png":{"ver":"1.0.1","uuid":"4e06ec01-eef0-4a2c-9e42-99d365650985","rawTextureUuid":"065474c4-463f-4abd-9e49-fef8358decee","type":"texture"},"按钮gray.png":{"ver":"1.0.1","uuid":"44563b27-de1f-43dc-a58d-8d5138a11ebf","rawTextureUuid":"065474c4-463f-4abd-9e49-fef8358decee","type":"texture"},"排行榜.png":{"ver":"1.0.1","uuid":"6a8d16c4-8f7e-4136-b06a-e29d8f0c6b4b","rawTextureUuid":"065474c4-463f-4abd-9e49-fef8358decee","type":"texture"},"规则-1.png":{"ver":"1.0.1","uuid":"e71b9d21-8d94-4fe5-afe4-96ac3abe75dd","rawTextureUuid":"065474c4-463f-4abd-9e49-fef8358decee","type":"texture"}},"type":"sheet"}
{"ver":"1.0.1","uuid":"a67a10bf-16e9-47b7-8f10-ee7dcdeb2551","subMetas":{},"isGroup":true}
{"ver":"1.0.1","uuid":"5250a5c7-c8ef-4c54-8578-26b68360d3d2","subMetas":{"bg":{"ver":"1.0.1","uuid":"32f7dcb5-758e-4267-aa81-a90c7062d2dc","rawTextureUuid":"5250a5c7-c8ef-4c54-8578-26b68360d3d2","type":"texture"}},"type":"texture","imagePath":"/Users/wanghongyuan/kickball0417/assets/singles/bg.jpg"}
{"ver":"1.0.1","uuid":"676f7693-a304-44e6-990d-c969603c8f84","subMetas":{"bg_play":{"ver":"1.0.1","uuid":"65004490-148c-4f78-a8ce-3169e813b971","rawTextureUuid":"676f7693-a304-44e6-990d-c969603c8f84","type":"texture"}},"type":"texture","imagePath":"/Users/wanghongyuan/kickball0417/assets/singles/bg_play.jpg"}
{
"ver": "1.0.1",
"uuid": "8ad59445-0ff2-4382-bb1c-9f7a07845e48",
"subMetas": {
"logo": {
"ver": "1.0.1",
"uuid": "c4c4d4b8-5178-4468-9460-c95435abefb8",
"rawTextureUuid": "8ad59445-0ff2-4382-bb1c-9f7a07845e48",
"type": "texture"
}
},
"type": "texture",
"imagePath": "/Users/rockyl/WorkSpaces/scilla/hello-scilla/assets/singles/logo.png"
}
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>kickball0417</title>
<meta name="viewport"
content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="screen-orientation" content="portrait"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<style>
html, body {
padding: 0;
margin: 0;
border: 0;
height: 100%;
background-color: #282C34;
}
</style>
</head>
<body>
<div id="gameContainer" style="width: 100%;height: 100%;overflow: hidden;"></div>
<script src="debug/bundle.js"></script>
<script>
setTimeout(function(){
var options = window['inputOptions'] || {};
window['kickball0417'].startup(document.getElementById('gameContainer'), options);
}, 100);
</script>
<script src='http://127.0.0.1:35729/livereload.js?ext=Chrome&extver=2.1.0'></script>
</body>
</html>
{
"name": "kickball0417",
"engineConfig": {
"fps": 60,
"designWidth": 750,
"designHeight": 1624,
"scaleMode": "fixedWidth",
"modifyCanvasSize": false,
"resPath": ""
},
"customConfig": {
"scene": {
"scenes": {
"main": "scenes/main.scene"
},
"entryScene": "main"
},
"webServiceUrl": "http://localhost:4001"
}
}
{
"code": "0000000000",
"data": {
"creditsConf": {
"creditsUp": 100,
"creditsType": "virtual",
"creditsDown": 50,
"prize": [
{
"img": "adsfsadf",
"credits": 20,
"id": 4,
"title": "0.3"
},
{
"img": "sadfasdf",
"credits": 150,
"id": 3,
"title": "1.5倍"
},
{
"img": "sadfasdf",
"credits": 100,
"id": 2,
"title": "1倍"
},
{
"img": "sadfasdf",
"credits": 50,
"id": 1,
"title": "0.5倍"
}
]
},
"floating": {
"jsTest": "//yun1.duiba.com.cn/h5/showCouponPrize/4.0.0/index_201710191434.js",
"cssTest": "//yun1.duiba.com.cn/h5/showCouponPrize/4.0.0/index_201710191440.css"
},
"options": [
{
"hidden": false,
"prizeType": "thanks",
"name": "谢谢参与",
"description": "",
"logo": "//yun1.duiba.com.cn/upload/uP99F1462438316972.png",
"id": 15581
},
{
"hidden": false,
"prizeType": "lucky",
"name": "幸运福袋",
"description": "",
"logo": "//yun1.duiba.com.cn/webapp/img/luckynewn.png",
"id": 15582
},
{
"itemId": 47861,
"scoreArea": "",
"hidden": false,
"prizeType": "alipay",
"name": "支付宝1",
"description": "",
"logo": "//yun1.duiba.com.cn/developer/img/activityTool/slotMachine/alipay.png",
"id": 15585
}
],
"rule": "adsfasdf",
"type": "hdtool",
"element": {
"isCreditsTypeOpen": false,
"myCreditsLong": 999999632167,
"freeLimit": -1,
"success": false,
"myCredits": "999999632167",
"needCredits": "100",
"freeEmpty": true,
"needCreditsLong": 100,
"status": 1
}
},
"success": true,
"desc": "OK",
"timestamp": 1548832971636
}
\ No newline at end of file
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1550564744291,
"data": {
"skincontent": "f2fcc331f44c98883f3a5b4868d7d7f4",
"throughInfo": [
{
"step": 3,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 4,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 5,
"prizeType": 2,
"description": null,
"img": ""
},
{
"step": 6,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 7,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 9,
"prizeType": 2,
"description": null,
"img": ""
},
{
"step": 10,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 11,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 13,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 15,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 16,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 18,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 19,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 21,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 22,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 24,
"prizeType": 1,
"description": null,
"img": ""
},
{
"step": 27,
"prizeType": 4,
"description": null,
"img": ""
}
]
}
}
\ No newline at end of file
{
"success":true,
"code":"0000000000",
"desc":"OK",
"timestamp":1548915321930,
"data":1
}
\ No newline at end of file
{"success":true,"code":"0000000000","desc":"OK","timestamp":1548915321930,"data":123456}
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1550569853824,
"data": {
"prizeType": "alipay",
"facePrice": "100",
"title": "1"
}
}
\ No newline at end of file
{
"success":true,
"code": 1,
"desc":"L(*ythj",
"timestamp":1548923950498
}
\ No newline at end of file
{"success":true,"code":"0000000000","desc":"OK","timestamp":1548923950498,"data":{"element":{"success":false,"isCreditsTypeOpen":false,"needCredits":"100","myCredits":"999999630434","myCreditsLong":999999630434,"needCreditsLong":100,"freeLimit":-1,"status":1,"freeEmpty":true},"lottery":{"id":null,"type":"thanks","imgUrl":null,"link":null,"title":null,"itemId":null,"appItemId":null,"bonus":null,"bonusMin":null,"bonusMax":null,"needAccount":null,"appLucky":null,"tip":null,"useBtnText":null,"validate":null,"couponCode":null,"couponKey":null,"stInfoDpmImg":null,"stInfoDpmClose":null,"stInfoDpmGoUse":null,"showUse":null,"openUrl":null,"iosDownloadUrl":null,"androidDownloadUrl":null,"isDownloadUrl":null,"confirm":null,"phaseNumber":null,"happyCode":null,"appHidden":true,"zybangJson":null},"exposure":null,"creditsInfo":{"activityId":82567,"prizeId":4,"orderNum":null,"developerBizId":"3029576","score":null,"recordStatus":1,"errorMsg":null},"againTag":null}}
{
"success":true,
"code":"0000000000",
"desc":"OK",
"timestamp":1548915321930,
"data":1
}
\ No newline at end of file
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1550570639368,
"data": {
"orderId": "883006813674240289",
"submitToken": "d895deb9118f4b938d0b70a3dd2ace19",
"credits": "999999491765",
"unitName": "金币",
"consumerCredits": 999999491765
}
}
\ No newline at end of file
{
"success":true,
"code":"0000000000",
"desc":"OK",
"timestamp":1548915321930,
"data":123456
}
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1550646190489,
"data": {
"score": 100,
"maxScore": 100
}
}
\ No newline at end of file
{
"success": true,
"code": 1,
"desc": "Hl7&L",
"timestamp": "1548915321930",
"data": "123123123"
}
\ No newline at end of file
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1551066205001,
"data": {
"resurrectionStatus": true,
"resurrectionCount": 2,
"resurrectionCredits": 300
}
}
\ No newline at end of file
{
"success": true,
"code": 0,
"desc": "ok",
"timestamp": "1519442544000",
"data": {
"valiDate": "2019-04-11 11:11:11",
"description": "xxx",
"title": "title",
"img": "//yun1.duiba.com.cn/upload/uP99F1462438316972.png"
}
}
\ No newline at end of file
{
"success":true,
"code":"0000000000",
"desc":"OK",
"timestamp":1548915321930,
"data":1
}
\ No newline at end of file
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1550647892216,
"data": "扣积分成功"
}
\ No newline at end of file
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1550568405622,
"data": {
"needPrize": true,
"lastThrough": null,
"currentLocation": 6,
"prizeType": 5,
"retreat": null,
"forward": null,
"url": null,
"plginOrderId": null,
"point": 5
}
}
\ No newline at end of file
{
"success": true,
"code": "0000000000",
"desc": "OK",
"timestamp": 1552025592298,
"data": {
"element": null,
"rule": null,
"questions": [
{
"id": 1,
"type": "text",
"name": "题目1",
"options": [
{
"optionId": 1,
"option": "1"
},
{
"optionId": 2,
"option": "2"
},
{
"optionId": 3,
"option": "3"
},
{
"optionId": 4,
"option": "4"
}
]
},
{
"id": 3,
"type": "text",
"name": "题目3",
"options": [
{
"optionId": 1,
"option": "1"
},
{
"optionId": 2,
"option": "2"
},
{
"optionId": 3,
"option": "3"
},
{
"optionId": 4,
"option": "4"
}
]
}
]
}
}
\ No newline at end of file
/**
* Created by rockyl on 2019-03-19.
*/
const glob = require('glob');
const fs = require('fs');
let files = glob.sync('src/**/!(index|registerAllComponents).ts');
let fileContent = `import {registerDef} from "scilla-core"
`;
const imports = [];
const contents = [];
for(let file of files){
let requirePath = '.' + file.replace('src', '').replace('.ts', '');
let fullClassName = file.replace('src', 'components').replace('.ts', '');
let shortClassName = fullClassName.substr(fullClassName.lastIndexOf('/') + 1);
imports.push(`import ${shortClassName} from '${requirePath}';`);
contents.push(` registerDef('${fullClassName}', ${shortClassName});`);
}
fileContent += imports.join('\n') + `
export function registerAllComponents(){
` + contents.join('\n') + '\n}';
fs.writeFileSync('src/registerAllComponents.ts', fileContent);
\ No newline at end of file
{
"_from": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"_id": "scilla-components@1.0.0",
"_inBundle": false,
"_integrity": "",
"_location": "/scilla-components",
"_phantomChildren": {},
"_requested": {
"type": "git",
"raw": "scilla-components@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",
"saveSpec": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"fetchSpec": "http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"gitCommittish": null
},
"_requiredBy": [
"/"
],
"_resolved": "git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git#7dbeb2b004d67c960aa4f52b679d80bb5f4c9110",
"_spec": "scilla-components@git+http://gitlab2.dui88.com/laoqifeng/scilla-components.git",
"_where": "/Users/wanghongyuan/kickball0417",
"bundleDependencies": false,
"deprecated": false,
"devDependencies": {
"glob": "^7.1.3",
"rollup-plugin-commonjs": "^9.2.2",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-typescript2": "^0.20.1",
"rollup-plugin-uglify": "^6.0.2",
"tslib": "^1.9.3",
"typescript": "^3.3.4000"
},
"license": "MIT",
"main": "./dist/index.js",
"name": "scilla-components",
"scripts": {},
"types": "./types/index.d.ts",
"version": "1.0.0"
}
/**
* Created by rockyl on 2018/11/16.
*/
const resolve = require('rollup-plugin-node-resolve');
const commonjs = require('rollup-plugin-commonjs');
const typescript = require('rollup-plugin-typescript2');
const {uglify} = require('rollup-plugin-uglify');
const name = 'scilla-components';
export default {
input: 'src/index.ts',
output: {
file: `dist/${name}.js`,
format: 'umd',
name,
//sourcemap: true,
},
plugins: [
resolve({
browser: true,
}),
typescript({
typescript: require('typescript'),
tslib: require('tslib'),
declaration: false,
}),
commonjs(),
//uglify({}),
],
external: ['scilla']
};
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
/**
* Created by rockyl on 2019-01-04.
*
* 弹动缩放
*/
import {createTween, Tween, Vector2D, createVector2D} from "scilla";
import ScillaComponent from "../base/ScillaComponent";
const originScale: Vector2D = createVector2D(1, 1);
export default class BounceZoom extends ScillaComponent {
targetScale: Vector2D = createVector2D(1.5, 1.5);
duration:number = 100;
private _tween: Tween;
onAwake() {
super.onAwake();
this._tween = createTween(this, this.transform, false,
{clazz: Vector2D, fields: ['x', 'y'], autoPlay: false}
)
.to({scale: this.targetScale.clone()}, this.duration * 0.5)
.to({scale: originScale.clone()}, this.duration * 0.5)
}
play(){
this._tween.play(true);
}
}
/**
* Created by rockyl on 2019-01-04.
*
* 渐变组件
*/
import {math} from "scilla";
import ScillaComponent from "../base/ScillaComponent";
export default class Fade extends ScillaComponent {
fromAlpha: number = 0;
toAlpha: number = 1;
duration: number = 1000;
private _startTime: number;
private _playing: boolean;
onUpdate(t) {
super.onUpdate(t);
if(this._playing){
if(!this._startTime){
this._startTime = t;
}
let ratio = (t - this._startTime) / this.duration;
this.transform.alpha = math.lerp(this.fromAlpha, this.toAlpha, ratio);
if(ratio >= 1){
this.stop();
}
}
}
play(){
this._startTime = 0;
this._playing = true;
}
stop(){
this._playing = false;
}
}
/**
* Created by rockyl on 2018/11/5.
*
* 自转组件
*/
import {createTween, ScillaEvent, Tween} from "scilla";
import ScillaComponent from "../base/ScillaComponent";
export default class Rotation extends ScillaComponent {
duration: number = 10000;
autoPlay: boolean = false;
loop: number = -1;
onComplete: ScillaEvent = new ScillaEvent();
private _tween: Tween;
onCreate() {
super.onCreate();
}
onAwake() {
super.onAwake();
if(!this._tween){
this._tween = createTween(this, this.transform, false, {autoPlay: this.autoPlay, loop: this.loop, initFields: ['_rotation']})
.to({rotation: 360}, this.duration)
.call(()=>{
this.onComplete.invoke();
});
}
}
play(){
this._tween.play(true);
}
stop(){
this._tween.stop();
}
}
/**
* Created by rockyl on 2018/11/5.
*/
import ScillaComponent from "../base/ScillaComponent";
export default class RoundLoop extends ScillaComponent {
transform;
duration: number = 10000;
onUpdate(t) {
super.onUpdate(t);
const {position} = this.transform;
position.setXY(
Math.cos(t * 0.001) * 100,
Math.sin(t * 0.001) * 100,
)
}
}
/**
* Created by rockyl on 2018/11/5.
*
* 摇摆组件
*/
import ScillaComponent from "../base/ScillaComponent";
export default class Swing extends ScillaComponent {
duration: number = 10000;
onUpdate(t) {
super.onUpdate(t);
this.transform.rotation = Math.sin(t / 100) * 5;
}
}
/**
* Created by rockyl on 2018-11-27.
*
* 触摸缩放交互效果组件
*/
import {createTween, createVector2D, ease, Ease, Tween, Vector2D,} from "scilla";
import {InteractComponent} from "../base";
export default class TouchZoom extends InteractComponent {
scaleOffset: Vector2D = createVector2D(0.1, 0.1);
duration: number = 200;
easeName: Ease = Ease.backOut;
private _zoomIn: Tween;
private _zoomOut: Tween;
private _touchBegin: boolean;
onAwake() {
super.onAwake();
if (!this._zoomIn) {
const {scaleOffset, duration, transform} = this;
const easeFunc = ease[this.easeName];
const scaleFrom = transform.scale.clone();
const scaleTo = transform.scale.clone().add(scaleOffset);
this._zoomIn = createTween(this, transform, false, {autoPlay: false, clazz: Vector2D, fields: ['x', 'y']})
.to({scale: scaleTo}, duration, easeFunc);
this._zoomOut = createTween(this, transform, false, {autoPlay: false, clazz: Vector2D, fields: ['x', 'y']})
.to({scale: scaleFrom}, duration, easeFunc);
}
}
onTouchBegin(e) {
super.onTouchOver(e);
if (this.interactable) {
this._touchBegin = true;
this._zoomIn.play(true);
}
}
onGlobalTouchEnd(e): boolean {
super.onGlobalTouchEnd(e);
if (this._touchBegin) {
this._touchBegin = false;
this._zoomOut.play(true);
}
return false;
}
}
/**
* Created by rockyl on 2018/11/5.
*
* 波动组件
*/
import {raw, ScillaEvent} from "scilla";
import ScillaComponent from "../base/ScillaComponent";
const PI2 = Math.PI * 2;
export enum WaveMethod {
/**
* 公转
*/
round = 'round',
/**
* 自转
*/
rotate = 'rotate',
/**
* 缩放
*/
zoom = 'zoom',
/**
* 透明渐变
*/
fade = 'fade',
/**
* 横向波动
*/
cosWave = 'cosWave',
/**
* 纵向波动
*/
sinWave = 'sinWave',
/**
* 抖动
*/
shake = 'shake',
/**
* 呼吸
*/
breath = 'breath',
}
export default class Wave extends ScillaComponent {
duration: number = 1000;
waveMethod: WaveMethod;
waveParams: raw;
loop: number = -1;
autoPlay: boolean = true;
onComplete: ScillaEvent = new ScillaEvent();
onLoopComplete: ScillaEvent = new ScillaEvent();
private _playing;
private _waveMethod;
private _startTime;
private _oldProps: any = {};
private _loopCounting;
onAwake() {
super.onAwake();
this._waveMethod = waveLibs[this.waveMethod];
this._startTime = 0;
const {transform: {position}} = this;
this._oldProps.x = position.x;
this._oldProps.y = position.y;
if (this.autoPlay) {
this.play();
}
}
onUpdate(t) {
super.onUpdate(t);
if (this._playing) {
if (!this._startTime) {
this._startTime = t;
}
const {duration, waveParams, _waveMethod, transform, transform: {position, scale}, _oldProps} = this;
let pass = (t - this._startTime) % duration;
let r = pass / duration * PI2;
let loopCounting = Math.floor((t - this._startTime) / duration);
if(loopCounting != this._loopCounting){
this._loopCounting = loopCounting;
if(this.onLoopEnd()){
r = PI2;
}
}
let params = waveParams || [];
let props = _waveMethod(...params, r);
if (props.hasOwnProperty('x')) {
position.x = (props.x || 0) + _oldProps.x;
}
if (props.hasOwnProperty('y')) {
position.y = (props.y || 0) + _oldProps.y;
}
if (props.hasOwnProperty('sx')) {
scale.x = props.sx;
}
if (props.hasOwnProperty('sy')) {
scale.y = props.sy;
}
if (props.hasOwnProperty('r')) {
transform.rotation = props.r;
}
}
}
private onLoopEnd(){
if (this.loop < 0) {
this.onLoopComplete.invoke();
} else if (this._loopCounting < this.loop) {
this.onLoopComplete.invoke();
} else {
this._playing = false;
this.onComplete.invoke();
return true;
}
}
play() {
this._loopCounting = 0;
this._playing = true;
this._startTime = 0;
}
stop() {
this._playing = false;
}
}
const {cos, sin, PI} = Math;
const waveLibs = {
round: function (h: number, t: number): any {
return {x: cos(t) * h, y: sin(t) * h};
},
cosWave: function (h: number, t: number): any {
return {x: cos(t) * h, y: 0};
},
sinWave: function (h: number, t: number): any {
h = h || 1;
return {x: 0, y: sin(t) * h};
},
rotate: function (t: number): any {
return {r: 360 * t / PI / 2};
},
shake: function (angle: number, count: number, t: number): any {
return {r: sin(t * count) * angle};
},
breath: function (scale: number = 0.1, t: number): any {
return {sx: sin(t) * scale + 1, sy: -sin(t + PI / 4) * scale + 1};
},
zoom: function (scale: number = 0.1, t: number): any {
return {sx: sin(t) * scale + 1, sy: sin(t) * scale + 1};
},
fade: function (base = 1, t: number): any {
return {alpha: (sin(t) + 1) * 0.5 + base};
},
};
/**
* Created by rockyl on 2018/11/5.
*/
import ScillaComponent from "../base/ScillaComponent";
export default class ZoomLoop extends ScillaComponent{
onUpdate(t) {
super.onUpdate(t);
this.transform.scale.x = this.transform.scale.y = Math.abs(Math.sin(t * 0.001)) * 0.15 + 1;
}
}
/**
* Created by rockyl on 2019-01-10.
*/
export {default as BounceZoom} from './BounceZoom'
export {default as Fade} from './Fade'
export {default as Rotation} from './Rotation'
export {default as RoundLoop} from './RoundLoop'
export {default as Swing} from './Swing'
export {default as TouchZoom} from './TouchZoom'
export {default as Wave} from './Wave'
export {default as ZoomLoop} from './ZoomLoop'
/**
* Created by rockyl on 2018/11/7.
*/
import {Matrix, decorators} from "scilla";
import Renderer from "../renderer/Renderer";
import ScillaComponent from "./ScillaComponent";
const {dirtyFieldTrigger} = decorators;
/**
* 可交互组件
*/
export default class InteractComponent extends ScillaComponent {
/**
* 是否可交互
*/
@dirtyFieldTrigger
interactable = true;
/**
* 触摸中断
*/
touchInterrupt: boolean = false;
protected invertMatrix = Matrix.create();
protected localPos: any = {};
protected isOut = true;
private _touchBeginFlag: boolean;
constructor() {
super();
}
_dealGlobalTouchBegin(e): boolean {
let interrupt = super._dealGlobalTouchBegin(e);
const hitOn = this.hitTest(e);
if (hitOn) {
this._touchBeginFlag = true;
this.onTouchBegin(e);
this._dealTouchOver(e);
}
return hitOn && (interrupt || this.touchInterrupt);
}
_dealGlobalTouchMove(e): boolean {
let interrupt = super._dealGlobalTouchMove(e);
const hitOn = this.hitTest(e);
if (hitOn) {
this._dealTouchOver(e);
this.onTouchMove(e);
} else {
this._dealTouchOut(e);
}
return hitOn && (interrupt || this.touchInterrupt);
}
_dealGlobalTouchEnd(e): boolean {
let interrupt = super._dealGlobalTouchEnd(e);
const hitOn = this.hitTest(e);
if (hitOn) {
this.onTouchEnd(e);
if(this._touchBeginFlag){
this.onTouchTap(e);
this._touchBeginFlag = false;
}
}
this.isOut = true;
return hitOn && (interrupt || this.touchInterrupt);
}
_dealTouchOver(e) {
if (this.isOut) {
this.isOut = false;
this.onTouchOver(e);
}
}
_dealTouchOut(e) {
if (!this.isOut) {
this.isOut = true;
this.onTouchOut(e);
}
}
onTouchBegin(e) {
//console.log('onTouchBegin', e);
}
onTouchMove(e) {
//console.log('onTouchMove', e);
}
onTouchOver(e) {
//console.log('onTouchOver', e);
}
onTouchOut(e) {
//console.log('onTouchOut', e);
}
onTouchEnd(e) {
//console.log('onTouchEnd', e);
}
onTouchTap(e) {
//console.log('onTouchTap', e);
}
/**
* 碰撞检测
* @param e
*/
hitTest(e): boolean {
const matrix = this.transform.getMatrix(true, true, true);
matrix.transformPoint(e.x, e.y, this.localPos);
let result = false;
const renderers = this.entity.getComponents(Renderer);
for (let renderer of renderers) {
if (renderer.hitTest(this.localPos.x, this.localPos.y)) {
if (!renderer['isUsedToMask']) {
result = true;
break
}
} else if (renderer['isUsedToMask']) {
return false
}
}
return result;
}
}
/**
* Created by rockyl on 2019-04-17.
*/
import {Component} from 'scilla'
import Transform from "./Transform";
export default class ScillaComponent extends Component{
get transform():Transform {
return this.entity.getComponentByName('components/base/Transform');
}
}
/**
* Created by rockyl on 2018-12-13.
*
* 触摸中断组件
*/
import InteractComponent from "./InteractComponent";
export default class TouchInterrupt extends InteractComponent {
touchInterrupt: boolean = true;
}
/**
* Created by rockyl on 2018/11/5.
*/
import {Vector2D, Matrix, decorators} from "scilla";
import Renderer from "../renderer/Renderer";
import ScillaComponent from "./ScillaComponent";
const {dirtyFieldDetector, dirtyFieldTrigger} = decorators;
/**
* 矩阵处理顺序
* SCALE_ROTATE: 先缩放后旋转
* ROTATE_SCALE: 先旋转后缩放
*/
export enum MATRIX_ORDER {
SCALE_ROTATE,
ROTATE_SCALE,
}
/**
* 矩阵转换组件
* 缩放、旋转、位移
*/
export default class Transform extends ScillaComponent {
onVector2DModify = (value, key, oldValue) => {
this.makeDirty(value, key, oldValue);
};
/**
* 坐标
*/
@dirtyFieldTrigger
position: Vector2D = new Vector2D(0, 0);
/**
* 全局坐标
*/
private _globalPosition: Vector2D = new Vector2D(0, 0);
/**
* 节点透明度
*/
@dirtyFieldTrigger
alpha: number = 1;
/**
* 节点渲染透明度
*/
private _renderAlpha: number;
get renderAlpha(): number {
return this._renderAlpha;
}
/**
* 影响子节点
*/
@dirtyFieldTrigger
affectChildren: boolean = true;
/**
* 尺寸
* 对于不同的子类渲染都有不同的效果
*/
private _width: number = NaN;
private _height: number = NaN;
/**
* 缩放
*/
@dirtyFieldTrigger
scale: Vector2D = new Vector2D(1, 1);
/**
* 轴距
*/
@dirtyFieldTrigger
pivot: Vector2D = new Vector2D(0.5, 0.5);
/**
* 旋转
*/
@dirtyFieldDetector
rotation = 0;
private order: MATRIX_ORDER = MATRIX_ORDER.SCALE_ROTATE;
protected _localMatrix: Matrix = Matrix.create();
protected _globalMatrix: Matrix = Matrix.create();
protected _globalInvertMatrix: Matrix = Matrix.create();
protected _globalPivotMatrix: Matrix = Matrix.create();
protected dirty: boolean;
get width(): number {
const renderer = this.entity.getComponent(Renderer);
return renderer ? renderer.bounds.width : (isNaN(this._width) ? 0 : this._width);
}
get explicitWidth(): number {
return this._width;
}
set width(value: number) {
if (this._width != value) {
this._width = value;
this.makeDirty(value, 'width');
}
}
get height(): number {
const renderer = this.entity.getComponent(Renderer);
return renderer ? renderer.bounds.height : (isNaN(this._height) ? 0 : this._height);
}
get explicitHeight(): number {
return this._height;
}
set height(value: number) {
if (this._height != value) {
this._height = value;
this.makeDirty(value, 'height');
}
}
/**
* 获取全局坐标
*/
get globalPosition() {
this._globalPosition.setXY(this._globalMatrix.tx, this._globalMatrix.ty);
return this._globalPosition;
}
/**
* 获取全局角度
*/
get globalRotation() {
return this._globalMatrix.rotation * 180 / Math.PI;
}
makeDirty(value, key, oldValue?) {
this.dirty = true;
switch (key) {
case 'width':
case 'height':
const renderers = this.entity.getComponents(Renderer);
for (let renderer of renderers) {
renderer.makeDirty();
}
break;
}
}
/**
* @inheritDoc
*/
onModify(value, key, oldValue) {
super.onModify(value, key, oldValue);
this.makeDirty(value, key, oldValue);
switch (key) {
case 'position':
case 'scale':
//case 'size':
value.onChange = this.onVector2DModify;
break;
}
}
/**
* 更新本地矩阵
*/
protected updateLocalMatrix() {
const {
position: {x, y},
scale: {x: sx, y: sy}, rotation,
} = this;
const matrix = this._localMatrix;
matrix.identity();
if (this.order === MATRIX_ORDER.SCALE_ROTATE) {
matrix.scale(sx, sy);
matrix.rotate(rotation * Math.PI / 180);
} else {
matrix.rotate(rotation * Math.PI / 180);
matrix.scale(sx, sy);
}
matrix.translate(
x,
y,
);
}
/**
* 更新全局矩阵
*/
protected updateGlobalMatrix() {
const {
entity, _globalMatrix, _localMatrix, _globalPivotMatrix,
pivot: {x: px, y: py},
width, height,
} = this;
_globalMatrix.copyFrom(_localMatrix);
if (entity.parent) {
const parentTransform: Transform = <Transform>entity.parent.getComponent(Transform);
if (parentTransform) {
this._renderAlpha = parentTransform._renderAlpha * this.alpha;
_globalMatrix.concat(parentTransform.getMatrix(true, false));
} else {
this._renderAlpha = this.alpha;
}
} else {
this._renderAlpha = this.alpha;
}
_globalPivotMatrix.copyFrom(_globalMatrix);
const {a, d} = _globalMatrix;
_globalPivotMatrix.translate(
-(px - 0.5) * width * a,
-(py - 0.5) * height * d,
);
}
/**
* 获取矩阵
*/
getMatrix(withPivot: boolean = false, invert: boolean = false, affectChildren = false): Matrix {
let matrix;
if(this.affectChildren || affectChildren){
matrix = withPivot ? this._globalPivotMatrix : this._globalMatrix;
if (invert) {
const invertMatrix = this._globalInvertMatrix;
invertMatrix.copyFrom(matrix);
invertMatrix.invert();
return invertMatrix;
}
}else{
matrix = this.entity.parent.getComponent(Transform).getMatrix(withPivot, invert);
}
return matrix;
}
onUpdate(t) {
if (this.dirty) {
this.updateLocalMatrix();
this.dirty = false;
}
this.updateGlobalMatrix();
super.onUpdate(t);
}
onEditorUpdate(t) {
this.onUpdate(t);
}
}
/**
* Created by rockyl on 2019-01-10.
*/
export {default as InteractComponent} from './InteractComponent'
export {default as TouchInterrupt} from './TouchInterrupt'
export {default as Transform} from './Transform'
/**
* Created by rockyl on 2019-01-24.
*/
export * from './animation';
export * from './base';
export * from './other';
export * from './renderer';
export * from './ui';
export * from './net';
export * from './registerAllComponents'
\ No newline at end of file
/**
* Created by rockyl on 2018-12-16.
*
* Api接口组件基类
*/
import {ScillaEvent} from "scilla";
import ScillaComponent from "../base/ScillaComponent";
export default class ApiComponent extends ScillaComponent {
onResponse: ScillaEvent = new ScillaEvent();
onError: ScillaEvent = new ScillaEvent();
onFinish: ScillaEvent = new ScillaEvent();
autoCall: boolean = false;
private _args;
onAwake() {
super.onAwake();
if(this.autoCall){
this.execute();
}
}
protected async execute(paramsInput?, ...args) {
this._args = args;
}
onGotResponse(response: any) {
if(this._args && this._args.length > 0){
this.onResponse.invoke(response, ...this._args);
}else{
this.onResponse.invoke(response);
}
this.onCallFinish();
}
onGotError(e) {
if(this._args && this._args.length > 0){
this.onError.invoke(e, ...this._args);
}else{
this.onError.invoke(e);
}
this.onCallFinish();
}
onCallFinish(){
if(this._args && this._args.length > 0){
this.onFinish.invoke(...this._args);
}else{
this.onFinish.invoke();
}
}
}
/**
* Created by hwj on 2018/12/1.
*
* 简单的api组件
*/
import {utils} from 'scilla'
import ApiComponent from "./ApiComponent";
import {callApi} from "./webService";
export default class SampleApi extends ApiComponent {
name: string;
uri: string;
method: string = 'POST';
params: any = {};
ignoreSuccessField: boolean = false;
async callApi(name, paramsInput, ...args){
if(this.name == name){
await this.execute(paramsInput, ...args);
}
}
protected async execute(paramsInput?, ...args) {
await super.execute(paramsInput, ...args);
const params = {
};
if(this.params){
utils.injectProp(params, this.params);
}
if(paramsInput){
utils.injectProp(params, paramsInput);
}
const {uri, method} = this;
try {
const response = await callApi(uri, params, method, 'json', this.ignoreSuccessField);
this.onGotResponse(response);
return response.data;
} catch (e) {
this.onGotError(e);
}
}
}
/**
* Created by hwj on 2018/12/1.
*
* 简单的api组件
*/
import {utils} from 'scilla'
import ApiComponent from "./ApiComponent";
import {callApi, polling} from "./webService";
export default class SamplePollingApi extends ApiComponent {
name: string;
successField: string;
successValues: any[];
uri: string;
method: string = 'GET';
params: any = {};
maxTimes: number = 5;
delay: number = 500;
async callApi(name, paramsInput, ...args) {
if (this.name == name) {
await this.execute(paramsInput, ...args);
}
}
protected async execute(paramsInput?, ...args) {
await super.execute(paramsInput, ...args);
const params = {
};
if (this.params) {
utils.injectProp(params, this.params);
}
if (paramsInput) {
utils.injectProp(params, paramsInput);
}
const {uri, method} = this;
try {
const response = await polling(this.successFunc, uri, params, this.maxTimes, this.delay, method);
this.onGotResponse(response);
return response.data;
} catch (e) {
this.onGotError(e);
}
}
successFunc=(response)=> {
const {successField, successValues} = this;
let v = successField ? response.data[successField] : response.data;
return successValues.indexOf(v) >= 0;
}
}
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取渲染数据
*/
export default class AjaxElementComponent extends SampleApi {
//唯一标识
name: string = 'ajaxElement';
//访问路径
uri: string = '/hdtool/recon/ajaxElement';
//请求方式
method: string = 'GET';
//duiba活动ID
duibaId: string;
//入库活动ID
activityId: string;
protected async execute() {
utils.injectProp(this.params, { duibaId: this.duibaId, activityId: this.activityId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 获取渲染数据
*/
export default class DoJoinComponent extends SampleApi {
//唯一标识
name: string = 'doJoin';
//访问路径
uri: string = '/hdtool/recon/doJoin';
//请求方式
method: string = 'GET';
//入库活动ID
activityId: string;
//token
token: string;
//再来一次订单ID
againOrderId: string;
//活动类型
activityType: string;
//用户ID
consumerId: string;
//积分
credits: number;
//分数 分段发奖
score: number;
protected async execute() {
utils.injectProp(this.params, {
activityId: this.activityId, token: this.token, againOrderId: this.againOrderId,
activityType: this.activityType, consumerId: this.consumerId, credits: this.credits, score: this.score
});
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 查询订单状态
*/
export default class GetOrderStatusComponent extends SampleApi {
//唯一标识
name: string = 'getOrderStatus';
//访问路径
uri: string = '/hdtool/recon/getOrderStatus';
//请求方式
method: string = 'POST';
//订单ID
orderId: string;
protected async execute() {
utils.injectProp(this.params, { orderId: this.orderId });
super.execute();
}
}
\ No newline at end of file
import { utils } from "scilla";
import SampleApi from "../../../SampleApi";
/**
* 查询奖品信息
*/
export default class PrizeDetailComponent extends SampleApi {
//唯一标识
name: string = 'prizeDetail';
//访问路径
uri: string = '/hdtool/recon/prizeDetail';
//请求方式
method: string = 'GET';
//
appItemId: string;
//
itemId: string;
//
appId: string;
protected async execute() {
utils.injectProp(this.params, { appItemId: this.appItemId, itemId: this.itemId, appId: this.appId });
super.execute();
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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