Commit 40d9d4fa authored by 任建锋's avatar 任建锋

--

parent 660c4f7e
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*60)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-50}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-500}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-540}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-500}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength+(this.nextLength-lastPos)}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength+(500-this.nextLength)}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength-(500-this.nextLength)}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-lastPos}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-lastPos-this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-lastPos+this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x-this.nextLength}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x: this.roadGroup["Transform"].position.x+lastPos}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x:this.roadGroup["Transform"].position.x-lastPos}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x:this.roadGroup["Transform"].position.x-(lastPos-500)}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
import InteractComponent from "scilla-components/src/base/InteractComponent";
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { dynamic,engine} from "scilla/src";
import { createSgin } from "../net/webService";
import { Entity, Tween } from "scilla/src";
import { Transform } from 'scilla-components/src';
import {createTween, ease} from "scilla";
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
doJoinData: dynamic;
getNgameStartStatus: dynamic;
bg1: Entity;
bg2: Entity;
bg3: Entity;
car: Entity;
bridge: Entity;
roadGroup: Entity;
road_0: Entity;
road_1: Entity;
road_2: Entity;
road_3: Entity;
life_1: Entity;
life_2: Entity;
life_3: Entity;
bottomGrass: Entity;
carImage: Entity;
score: number;
firstGui: Entity;
onAwake() {
super.onAwake();
this.bottomGrass["Transform"] = this.bottomGrass.getComponent(Transform);
this.firstGui["Transform"] = this.firstGui.getComponent(Transform);
this.car["Transform"] = this.car.getComponent(Transform);
this.carImage["Transform"] = this.carImage.getComponent(Transform);
this.bridge["Transform"] = this.bridge.getComponent(Transform);
this.roadGroup["Transform"] = this.roadGroup.getComponent(Transform);
this.road_0["Transform"] = this.road_0.getComponent(Transform);
this.road_1["Transform"] = this.road_1.getComponent(Transform);
this.road_2["Transform"] = this.road_2.getComponent(Transform);
this.road_3["Transform"] = this.road_3.getComponent(Transform);
this.bottomGrass["Transform"].position.y=engine.renderContext.stageSize.height;
this.setFirstGui()
this.setCarAnimation()
this.bridgeInit()
this.roadInit()
}
onClick_firstGui(){
this.setVisible(this.firstGui,false)
}
//引导页
setFirstGui(){
if(localStorage["firstGui"+window["CFG"].actId]){
this.setVisible(this.firstGui,false)
}else{
localStorage["firstGui"+window["CFG"].actId]="1";
this.setVisible(this.firstGui,true)
}
}
setCarAnimation(){
createTween(this, this.carImage["Transform"],true,{loop:-1})
.set({scale: {x: 1, y: 1},position:{x:0,y:0}})
.to({scale: {x: .98, y: .98},position:{x:.5,y:.5}}, 50)
.to({scale: {x: 1, y: 1},position:{x:-.5,y:-.5}}, 50)
}
//是否隐藏对象
setVisible(obj,state){
if(state){
obj["Transform"].alpha=1;
obj.enabled=true;
}else{
obj["Transform"].alpha=0;
obj.enabled=false;
}
}
roadIndex=1
roadInit(){
this.roadIndex=1
}
carInit(){
this.car["Transform"].position.x=105
this.car["Transform"].position.y=807.5
}
carGo(){
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x+this.nextLength}}, 500)
.call(()=>{
console.log(2233)
this.roadGo()
})
}
nextLength=450+(Math.random()*60)
roadGo(){
this.roadIndex++
if(this.roadIndex>3){
this.roadIndex=1;
}
var lastPos
console.log(this.roadIndex)
//缓存当前平台的位置
lastPos=this["road_"+(this.roadIndex)]["Transform"].position.x
//设置下一个平台的位置
this.nextLength=450+(Math.random()*50)
//移动平台
createTween(this, this.roadGroup["Transform"],true,{loop:0})
.to({position: {x:this.roadGroup["Transform"].position.x-lastPos)}}, 500)
.call(()=>{
if(this.roadIndex<3){
this["road_"+(this.roadIndex+1)]["Transform"].position.x=lastPos+this.nextLength
}else{
console.log()
this["road_1"]["Transform"].position.x=lastPos+this.nextLength
}
})
//移动车辆
createTween(this, this.car["Transform"],true,{loop:0})
.to({position: {x: this.car["Transform"].position.x-this.nextLength}}, 500)
this.bridgeGo()
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = true;
setTimeout(() => {
//this.bubbling('fuck', 'start');
//this.onGameOver();
}, 3000);
}
onGameOver() {
this.ngameSubmit();
}
ngameSubmit() {
console.log('createSgin', this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const sign = createSgin(this.doJoinData, this.score, '[]', this.getNgameStartStatus.submitToken);
const param: any = {
orderId: this.doJoinData,
score: this.score,
gameData: '[]',
sgin: sign,
dynamicData: '[]'
};
this.broadcast('callApi', 1, 'ngameSubmit', param);
}
onResponse_ngameSubmit() {
this.bubbling('showDialog', 'GameOver');
}
bridgeState=false
onGlobalTouchBegin(e){
console.log("begin")
this.bridgeState=true
this.bridgeReset()
}
onGlobalTouchEnd(e){
console.log("end")
this.bridgeState=false
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({rotation:0 }, 400)
.call(()=>{
this.carGo()
})
}
onGlobalTouchMove(){
console.log("move")
}
bridgeInit(){
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
this.bridge["Transform"].scale.x=0;
}
bridgeReset(){
this.bridgeX=0;
this.bridge["Transform"].scale.x=0
this.bridge["Transform"].position.x=205;
this.bridge["Transform"].position.y=892;
}
bridgeGo(){
createTween(this, this.bridge["Transform"],true,{loop:0})
.to({position: {x: this.bridge["Transform"].position.x-500}}, 500)
.call(()=>{
//this.carGo()
})
}
bridgeX=0;
onEnterFrame(){
if(this.bridge["Transform"]){
if(this.bridgeState){
this.bridgeX+=20
this.bridge["Transform"].scale.x=this.bridgeX/350;
this.bridge["Transform"].rotation=-90;
}
}
}
onError_ngameSubmit() {
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
this.entity.enabled = false;
}
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;
}
onUpdate(t){
super.onUpdate(t)
this.onEnterFrame()
}
}
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