Commit 48b2c0e6 authored by wildfirecode's avatar wildfirecode

1

parent a9cf7d61
......@@ -67,7 +67,7 @@
"BallItemPrefab": "res|8ebdfe78-ea44-445d-8bbe-02a22874e896",
"RedFirePrefab": "res|83d50df9-266c-478f-bf01-21d478abe049",
"BlueRocketPrefab": "res|9a8fe57a-ff20-44e7-89bf-cdc95e80e1ea",
"car": "entity|a5b807ba-098f-4b6e-b0da-e42b6324f62a"
"car": "entity|ebfde024-e9b9-40cb-a866-c0b194446b35"
}
}
],
......@@ -214,132 +214,153 @@
"children": []
},
{
"name": "car",
"name": "carWrapper",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": -48.452380952380956,
"y": 420.7142857142857
"x": 2.5,
"y": 340,
"_type_": "scilla/support/Vector2D"
}
}
},
{
"script": "components/other/RelativeLayout",
"script": "components/renderer/RectRenderer",
"properties": {
"top": 1200
}
"width": 120,
"height": 110
},
"disabled": false
}
],
"uuid": "a5b807ba-098f-4b6e-b0da-e42b6324f62a",
"uuid": "ebfde024-e9b9-40cb-a866-c0b194446b35",
"children": [
{
"name": "Image",
"name": "car",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 52.5,
"y": -22.5
"x": -52,
"y": 50.5,
"_type_": "scilla/support/Vector2D"
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|abdded14-a2d2-4000-b264-9ff47c843149"
}
}
],
"uuid": "396837ee-1f43-496e-aa64-d2a3bd65b53d"
},
{
"name": "Image",
"components": [
"uuid": "a5b807ba-098f-4b6e-b0da-e42b6324f62a",
"children": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 52.85714285714286,
"y": -57.14285714285715
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 52.5,
"y": -22.5
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|abdded14-a2d2-4000-b264-9ff47c843149"
}
}
}
],
"uuid": "396837ee-1f43-496e-aa64-d2a3bd65b53d"
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|ade44f23-754d-4923-a713-76f4207c3bde"
}
}
],
"uuid": "5e34a5e7-e298-4fda-a244-737cb992bc81"
},
{
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 10,
"y": -12.8,
"_type_": "scilla/support/Vector2D"
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 52.85714285714286,
"y": -57.14285714285715
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|ade44f23-754d-4923-a713-76f4207c3bde"
}
}
}
],
"uuid": "5e34a5e7-e298-4fda-a244-737cb992bc81"
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|cb4651fa-3d76-43c6-89a9-d06ddda3c110"
}
}
],
"uuid": "a72826e5-eaf9-40a8-aa6a-3a1681c1370f"
},
{
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 97.14285714285714,
"y": -12.8,
"_type_": "scilla/support/Vector2D"
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 10,
"y": -12.8,
"_type_": "scilla/support/Vector2D"
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|cb4651fa-3d76-43c6-89a9-d06ddda3c110"
}
}
}
],
"uuid": "a72826e5-eaf9-40a8-aa6a-3a1681c1370f"
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|cb4651fa-3d76-43c6-89a9-d06ddda3c110"
}
}
],
"uuid": "b9f27fea-f7e9-4ebe-a89d-74dc894405d0"
},
{
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 51.42857142857143,
"y": -115.71428571428572
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 97.14285714285714,
"y": -12.8,
"_type_": "scilla/support/Vector2D"
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|cb4651fa-3d76-43c6-89a9-d06ddda3c110"
}
}
}
],
"uuid": "b9f27fea-f7e9-4ebe-a89d-74dc894405d0"
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|f67e2e09-e0f4-4aea-8243-8d86a4ded38a"
}
"name": "Image",
"components": [
{
"script": "components/base/Transform",
"properties": {
"position": {
"x": 51.42857142857143,
"y": -115.71428571428572
}
}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|f67e2e09-e0f4-4aea-8243-8d86a4ded38a"
}
}
],
"uuid": "7779fb7e-1935-4600-beb2-bd86ed7cbf44"
}
],
"uuid": "7779fb7e-1935-4600-beb2-bd86ed7cbf44"
]
}
]
}
......@@ -692,7 +713,7 @@
"entity-cache": [
"f02aa1f7-3255-405e-a537-7ba4ef503aa7",
"70838016-4fab-4a0f-90aa-61c4303a4ecc",
"a5b807ba-098f-4b6e-b0da-e42b6324f62a",
"ebfde024-e9b9-40cb-a866-c0b194446b35",
"91e550e7-aba1-4eaf-bb74-04c7e7789102",
"3b5cb573-bb7b-46f2-af0b-8e6ca7380dcc",
"adf5cdd6-0cff-47a1-b3ae-8a28fc11b29c",
......
......@@ -25,12 +25,12 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
bodys: Entity[];
onGlobalTouchBegin(e): any {
this.car.getComponent(Transform).position.x=e.x-375;
this.car.getComponent(Transform).position.x = e.x - 375;
return super.onGlobalTouchBegin(e);
}
onGlobalTouchMove(e: { x, y }) {
this.car.getComponent(Transform).position.x=e.x-375;
this.car.getComponent(Transform).position.x = e.x - 375;
return super.onGlobalTouchMove(e);
}
......@@ -68,13 +68,13 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
for (const body of this.bodys) {
const { position } = body.getComponent(Transform);
const pic = body.getChildrenByName('pic')[0];
const { height } = pic.getComponent(Transform);
const r = height / 2;
const { height, width } = pic.getComponent(Transform);
const r = height / 2;//刚体的半径
// console.log(position.x);
// console.log(position.y + r)
if (position.y + r > GROUND_Y) {
position.y = GROUND_Y - r;
body.getComponent(Body).revertY();
}
if (position.x + r > 375) {
......@@ -86,9 +86,36 @@ export default class ScenePlay extends InteractComponent implements INavigatorVi
position.x = -375 + r;
body.getComponent(Body).revertX();
}
const { x: carX, y: carY } = this.car.getComponent(Transform).position;
//判断car与body的碰撞
const x0 = Math.abs(position.x - carX);
const y0 = Math.abs(position.y - carY);
const x1 = r + 120 / 2;
const y1 = r + 110 / 2;
if (x0 < x1 && y0 < y1) {
console.log('碰撞了');
this.onCarCollideDrops(body);
}
}
}
async onCarCollideDrops(body: Entity) {
const index = this.bodys.indexOf(body);
if (index == -1) return;
this.bodys.splice(index, 1);
body.removeComponent(body.getComponent(Body));
await this.playCollexctDropsAni();
this.entity.removeChild(body);
}
async playCollexctDropsAni() {
return new Promise((r) => {
setTimeout(() => {
r();
}, 1000);
})
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
(this.entity.getComponent(Transform) as Transform).alpha = 1;
// this.getBallItem();
......
This diff is collapsed.
This diff is collapsed.
......@@ -5,47 +5,47 @@
import {registerDef} from 'scilla'
import component0 from 'components/animation/TouchZoom';
registerDef('components/animation/TouchZoom', component0);
import component0 from 'components/base/Transform';
registerDef('components/base/Transform', component0);
import component1 from 'components/base/Transform';
registerDef('components/base/Transform', component1);
import component1 from 'components/other/FullStageSize';
registerDef('components/other/FullStageSize', component1);
import component2 from 'components/renderer/RectRenderer';
registerDef('components/renderer/RectRenderer', component2);
import component2 from 'components/renderer/TextureRenderer';
registerDef('components/renderer/TextureRenderer', component2);
import component3 from 'components/other/FullStageSize';
registerDef('components/other/FullStageSize', component3);
import component3 from 'components/other/RelativeLayout';
registerDef('components/other/RelativeLayout', component3);
import component4 from 'components/base/TouchInterrupt';
registerDef('components/base/TouchInterrupt', component4);
import component4 from 'components/renderer/TextRenderer';
registerDef('components/renderer/TextRenderer', component4);
import component5 from 'components/renderer/TextureRenderer';
registerDef('components/renderer/TextureRenderer', component5);
import component5 from 'components/renderer/RectRenderer';
registerDef('components/renderer/RectRenderer', component5);
import component6 from 'components/other/RelativeLayout';
registerDef('components/other/RelativeLayout', component6);
import component6 from 'components/other/CameraController';
registerDef('components/other/CameraController', component6);
import component7 from 'components/renderer/TextRenderer';
registerDef('components/renderer/TextRenderer', component7);
import component7 from 'components/animation/TouchZoom';
registerDef('components/animation/TouchZoom', component7);
import component8 from 'components/ui/Button';
registerDef('components/ui/Button', component8);
import component9 from 'components/other/CameraController';
registerDef('components/other/CameraController', component9);
import component9 from 'components/base/TouchInterrupt';
registerDef('components/base/TouchInterrupt', component9);
import component10 from '../../assets/scripts/scenes/SceneStart';
registerDef('./scripts/scenes/SceneStart', component10);
import component10 from '../../assets/scripts/scenes/ScenePlay';
registerDef('./scripts/scenes/ScenePlay', component10);
import component11 from '../../assets/scripts/popup/Popup';
registerDef('./scripts/popup/Popup', component11);
import component11 from '../../assets/scripts/navigator/SingleSceneNavigator';
registerDef('./scripts/navigator/SingleSceneNavigator', component11);
import component12 from '../../assets/scripts/scenes/ScenePlay';
registerDef('./scripts/scenes/ScenePlay', component12);
import component12 from '../../assets/scripts/popup/Popup';
registerDef('./scripts/popup/Popup', component12);
import component13 from '../../assets/scripts/navigator/SingleSceneNavigator';
registerDef('./scripts/navigator/SingleSceneNavigator', component13);
import component13 from '../../assets/scripts/scenes/RedFireItem';
registerDef('./scripts/scenes/RedFireItem', component13);
import component14 from '../../assets/scripts/dialogs/RulePanel';
registerDef('./scripts/dialogs/RulePanel', component14);
......@@ -53,9 +53,8 @@ registerDef('./scripts/dialogs/RulePanel', component14);
import component15 from '../../assets/scripts/scenes/BallItem';
registerDef('./scripts/scenes/BallItem', component15);
import component16 from '../../assets/scripts/scenes/BlueRocketItem';
registerDef('./scripts/scenes/BlueRocketItem', component16);
import component17 from '../../assets/scripts/scenes/BlueRocketItem';
registerDef('./scripts/scenes/BlueRocketItem', component17);
import component18 from '../../assets/scripts/scenes/RedFireItem';
registerDef('./scripts/scenes/RedFireItem', component18);
import component17 from '../../assets/scripts/scenes/SceneStart';
registerDef('./scripts/scenes/SceneStart', component17);
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