Commit 48b2c0e6 authored by wildfirecode's avatar wildfirecode

1

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