Commit a9cf7d61 authored by wildfirecode's avatar wildfirecode

1

parent 87ed75e2
......@@ -22,15 +22,11 @@
{
"script": "./scripts/scenes/BallItem",
"properties": {}
},
{
"script": "./scripts/scenes/testC",
"properties": {}
}
],
"children": [
{
"name": "Image",
"name": "pic",
"components": [
{
"script": "components/base/Transform",
......
{
"name": "BlueRocket",
"root": {
"uuid": "20190301114308",
"components": [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
}
],
"children": [
{
"uuid": "20190301114245",
"name": "BlueRocket",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "./scripts/scenes/BlueRocketItem",
"properties": {}
}
],
"children": [
{
"name": "pic",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
{
"script": "components/renderer/TextureRenderer",
"properties": {
"texture": "res|aa4bc010-fa6b-4194-8795-8321390f0ff4"
}
}
],
"uuid": "8880bafc-d2cd-4e48-bd4d-4b0db91e23c8"
}
]
}
]
},
"entity-cache": []
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"9a8fe57a-ff20-44e7-89bf-cdc95e80e1ea","subMetas":{},"type":"prefab"}
......@@ -26,7 +26,7 @@
],
"children": [
{
"name": "Image",
"name": "pic",
"components": [
{
"script": "components/base/Transform",
......
......@@ -65,7 +65,9 @@
"bulletNumTxt": "entity|f02aa1f7-3255-405e-a537-7ba4ef503aa7",
"strengthNumTxt": "entity|70838016-4fab-4a0f-90aa-61c4303a4ecc",
"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",
"car": "entity|a5b807ba-098f-4b6e-b0da-e42b6324f62a"
}
}
],
......@@ -690,6 +692,7 @@
"entity-cache": [
"f02aa1f7-3255-405e-a537-7ba4ef503aa7",
"70838016-4fab-4a0f-90aa-61c4303a4ecc",
"a5b807ba-098f-4b6e-b0da-e42b6324f62a",
"91e550e7-aba1-4eaf-bb74-04c7e7789102",
"3b5cb573-bb7b-46f2-af0b-8e6ca7380dcc",
"adf5cdd6-0cff-47a1-b3ae-8a28fc11b29c",
......@@ -704,6 +707,10 @@
"uuid": "8ebdfe78-ea44-445d-8bbe-02a22874e896",
"url": "prefabs/BallItem.pfb"
},
{
"uuid": "9a8fe57a-ff20-44e7-89bf-cdc95e80e1ea",
"url": "prefabs/BlueRocket.pfb"
},
{
"uuid": "83d50df9-266c-478f-bf01-21d478abe049",
"url": "prefabs/RedFire.pfb"
......
......@@ -5,7 +5,7 @@
*/
export module alien {
export enum NavigatorAction {Push, Pop, Replace, Jump}
export enum NavigatorAction { Push, Pop, Replace, Jump }
export interface INavigatorDelegate {
onEnter(name: string, last: string, action: NavigatorAction, parameters: any);
......@@ -79,14 +79,14 @@ export module alien {
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Replace, parameters));
}
jump(name: string, parameters: any = null){
if(this._stack.length < 2){
jump(name: string, parameters: any = null) {
if (this._stack.length < 2) {
this.push(name, parameters);
return;
}
let last:string = this._stack.pop();
let last: string = this._stack.pop();
this._stack.splice(1);
let next:string = name;
let next: string = name;
this._stack.push(next);
this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters);
this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters);
......
......@@ -117,6 +117,6 @@ export class VirtualNavigator extends EventEmitter implements INavigatorDelegate
* @param error
*/
onError(error: Error) {
console.log(error)
}
}
import Body from './Body';
export default class BlueRocketItem extends Body {
constructor() {
super();
this.bounceY = 0.9;
}
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"3271100c-b1f8-4443-9b90-421ec1c36fcd","subMetas":{},"type":"script"}
{"ver":"1.0.1","uuid":"7d528d53-7759-4082-ae57-f1d56666ca4b","subMetas":{},"type":"script"}
......@@ -3,20 +3,28 @@ import { Transform } from 'scilla-components/src';
import { gravityY } from './gameconst';
export default class Body extends ScillaComponent {
bounceY = 0;
bounceY = 1;
bounceX = 1;
velocityY = 0;
velocityX = 0;
rotationSpeed = 0.5;
private _counter = 0;
onUpdate() {
this._counter++;
const { entity } = this;
this.velocityY += gravityY;
entity.getComponent(Transform).position.y += this.velocityY;
entity.getComponent(Transform).position.x += this.velocityX;
// console.log(entity.getComponent(Transform).position.y)
entity.getComponent(Transform).rotation = this._counter * .7 * this.rotationSpeed;
}
revertY() {
this.velocityY *= -1 * this.bounceY;
}
revertX() {
this.velocityX*= -1 * this.bounceY;
this.velocityX *= -1 * this.bounceX;
}
}
\ No newline at end of file
import Body from './Body';
export default class RedFireItem extends Body {
constructor() {
super();
this.bounceY = 0.9;
}
}
\ No newline at end of file
/**
* Created by rockyl on 2019-04-09.
*/
import InteractComponent from 'components/base/InteractComponent';
import { Entity, instantiate, resource } from "scilla";
import { Transform } from 'scilla-components/src';
import ScillaComponent from 'scilla-components/src/base/ScillaComponent';
import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import BallItem from './BallItem';
import RedFireItem from './RedFireItem';
import BlueRocketItem from './BlueRocketItem';
import Body from './Body';
import RedFireItem from './RedFireItem';
const GROUND_Y = 250; //碰到地板时,球的中心点的y
export default class ScenePlay extends ScillaComponent implements INavigatorViewBase {
const GROUND_Y = 350 + 40; //碰到地板时,球的中心点的y
export default class ScenePlay extends InteractComponent implements INavigatorViewBase {
BallItemPrefab: resource;
RedFirePrefab: resource;
BlueRocketPrefab: resource;
bulletNumTxt: Entity;
strengthNumTxt: Entity;
car: Entity;
// ballList: Entity[];
// redFireList: Entity[];
bodys: Entity[];
onGlobalTouchBegin(e): any {
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;
return super.onGlobalTouchMove(e);
}
getRedFireItem() {
const redFire = instantiate(this.RedFirePrefab);
this.entity.addChild(redFire);
this.bodys.push(redFire);
const item = instantiate(this.RedFirePrefab);
this.entity.addChild(item);
this.bodys.push(item);
item.getComponent(RedFireItem).velocityX = 1;
// this.redFireList.push(redFire);
redFire.getComponent(RedFireItem).bounceY = 0.9;
// redFire.getComponent(RedFireItem).
}
getBlueRocketItem() {
const item = instantiate(this.BlueRocketPrefab);
this.entity.addChild(item);
this.bodys.push(item);
// this.redFireList.push(redFire);
item.getComponent(BlueRocketItem).velocityX = 1;
}
getBallItem() {
const ball = instantiate(this.BallItemPrefab);
ball.getComponent(Transform).position.y = -300;
this.bodys.push(ball);
this.entity.addChild(ball);
// this.ballList.push(ball);
this.bodys.push(ball);
ball.getComponent(BallItem).bounceY = 1;
}
onAwake() {
......@@ -47,9 +67,24 @@ export default class ScenePlay extends ScillaComponent implements INavigatorView
onUpdate() {
for (const body of this.bodys) {
const { position } = body.getComponent(Transform);
if (position.y > GROUND_Y) {
position.y = GROUND_Y;
const pic = body.getChildrenByName('pic')[0];
const { height } = pic.getComponent(Transform);
const r = height / 2;
// 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) {
position.x = 375 - r;
body.getComponent(Body).revertX();
}
if (position.x - r < -375) {
position.x = -375 + r;
body.getComponent(Body).revertX();
}
}
}
......@@ -58,6 +93,7 @@ export default class ScenePlay extends ScillaComponent implements INavigatorView
(this.entity.getComponent(Transform) as Transform).alpha = 1;
// this.getBallItem();
this.getRedFireItem();
// this.getBlueRocketItem();
}
onDidLeave(next: string, action: alien.NavigatorAction, parameters: any): void {
......
import ScillaComponent from 'scilla-components/src/base/ScillaComponent';
export default class testC extends ScillaComponent{
onAwake(){
super.onAwake();
console.log('im testC')
}
onUpdate(t){
super.onUpdate(t);
}
}
No preview for this file type
......@@ -7089,59 +7089,82 @@
__extends(Body, _super);
function Body() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.bounceY = 0;
_this.bounceY = 1;
_this.bounceX = 1;
_this.velocityY = 0;
_this.velocityX = 0;
_this.rotationSpeed = 0.5;
_this._counter = 0;
return _this;
}
Body.prototype.onUpdate = function () {
this._counter++;
var entity = this.entity;
this.velocityY += gravityY;
entity.getComponent(Transform).position.y += this.velocityY;
entity.getComponent(Transform).position.x += this.velocityX;
entity.getComponent(Transform).rotation = this._counter * .7 * this.rotationSpeed;
};
Body.prototype.revertY = function () {
this.velocityY *= -1 * this.bounceY;
};
Body.prototype.revertX = function () {
this.velocityX *= -1 * this.bounceY;
this.velocityX *= -1 * this.bounceX;
};
return Body;
}(ScillaComponent));
var BallItem = (function (_super) {
__extends(BallItem, _super);
function BallItem() {
return _super !== null && _super.apply(this, arguments) || this;
var BlueRocketItem = (function (_super) {
__extends(BlueRocketItem, _super);
function BlueRocketItem() {
var _this = _super.call(this) || this;
_this.bounceY = 0.9;
return _this;
}
return BallItem;
return BlueRocketItem;
}(Body));
var RedFireItem = (function (_super) {
__extends(RedFireItem, _super);
function RedFireItem() {
return _super !== null && _super.apply(this, arguments) || this;
var _this = _super.call(this) || this;
_this.bounceY = 0.9;
return _this;
}
return RedFireItem;
}(Body));
var GROUND_Y = 250;
var GROUND_Y = 350 + 40;
var ScenePlay = (function (_super) {
__extends(ScenePlay, _super);
function ScenePlay() {
return _super !== null && _super.apply(this, arguments) || this;
}
ScenePlay.prototype.onGlobalTouchBegin = function (e) {
this.car.getComponent(Transform).position.x = e.x - 375;
return _super.prototype.onGlobalTouchBegin.call(this, e);
};
ScenePlay.prototype.onGlobalTouchMove = function (e) {
this.car.getComponent(Transform).position.x = e.x - 375;
return _super.prototype.onGlobalTouchMove.call(this, e);
};
ScenePlay.prototype.getRedFireItem = function () {
var redFire = instantiate(this.RedFirePrefab);
this.entity.addChild(redFire);
this.bodys.push(redFire);
redFire.getComponent(RedFireItem).bounceY = 0.9;
var item = instantiate(this.RedFirePrefab);
this.entity.addChild(item);
this.bodys.push(item);
item.getComponent(RedFireItem).velocityX = 1;
};
ScenePlay.prototype.getBlueRocketItem = function () {
var item = instantiate(this.BlueRocketPrefab);
this.entity.addChild(item);
this.bodys.push(item);
item.getComponent(BlueRocketItem).velocityX = 1;
};
ScenePlay.prototype.getBallItem = function () {
var ball = instantiate(this.BallItemPrefab);
this.entity.addChild(ball);
ball.getComponent(Transform).position.y = -300;
this.bodys.push(ball);
ball.getComponent(BallItem).bounceY = 1;
this.entity.addChild(ball);
};
ScenePlay.prototype.onAwake = function () {
_super.prototype.onAwake.call(this);
......@@ -7153,10 +7176,21 @@
for (var _b = __values(this.bodys), _c = _b.next(); !_c.done; _c = _b.next()) {
var body = _c.value;
var position = body.getComponent(Transform).position;
if (position.y > GROUND_Y) {
position.y = GROUND_Y;
var pic = body.getChildrenByName('pic')[0];
var height = pic.getComponent(Transform).height;
var r = height / 2;
if (position.y + r > GROUND_Y) {
position.y = GROUND_Y - r;
body.getComponent(Body).revertY();
}
if (position.x + r > 375) {
position.x = 375 - r;
body.getComponent(Body).revertX();
}
if (position.x - r < -375) {
position.x = -375 + r;
body.getComponent(Body).revertX();
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
......@@ -7195,7 +7229,7 @@
return undefined;
};
return ScenePlay;
}(ScillaComponent));
}(InteractComponent));
var alien;
(function (alien) {
......@@ -7375,6 +7409,7 @@
});
};
VirtualNavigator.prototype.onError = function (error) {
console.log(error);
};
return VirtualNavigator;
}(EventEmitter));
......@@ -7442,20 +7477,13 @@
return RulePanel;
}(DialogContent));
var testC = (function (_super) {
__extends(testC, _super);
function testC() {
var BallItem = (function (_super) {
__extends(BallItem, _super);
function BallItem() {
return _super !== null && _super.apply(this, arguments) || this;
}
testC.prototype.onAwake = function () {
_super.prototype.onAwake.call(this);
console.log('im testC');
};
testC.prototype.onUpdate = function (t) {
_super.prototype.onUpdate.call(this, t);
};
return testC;
}(ScillaComponent));
return BallItem;
}(Body));
registerDef('components/animation/TouchZoom', TouchZoom);
registerDef('components/base/Transform', Transform);
......@@ -7473,7 +7501,7 @@
registerDef('./scripts/navigator/SingleSceneNavigator', SingleSceneNavigator);
registerDef('./scripts/dialogs/RulePanel', RulePanel);
registerDef('./scripts/scenes/BallItem', BallItem);
registerDef('./scripts/scenes/testC', testC);
registerDef('./scripts/scenes/BlueRocketItem', BlueRocketItem);
registerDef('./scripts/scenes/RedFireItem', RedFireItem);
modifyEngineConfig({
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -53,8 +53,9 @@ registerDef('./scripts/dialogs/RulePanel', component14);
import component15 from '../../assets/scripts/scenes/BallItem';
registerDef('./scripts/scenes/BallItem', component15);
import component16 from '../../assets/scripts/scenes/testC';
registerDef('./scripts/scenes/testC', component16);
import component17 from '../../assets/scripts/scenes/RedFireItem';
registerDef('./scripts/scenes/RedFireItem', component17);
import component17 from '../../assets/scripts/scenes/BlueRocketItem';
registerDef('./scripts/scenes/BlueRocketItem', 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