Commit 1e3632af authored by wildfirecode's avatar wildfirecode

1

parent bbbdbae3
{
"name": "test",
"root": {
"uuid": "20190301114308",
components: [
{
"script": "components/base/Transform"
},
{
"script": "components/other/CameraController"
},
],
"children": [
{
"uuid": "20190301114245",
"name": "test",
"components": [
{
"script": "components/base/Transform",
"properties": {}
},
]
}
]
},
"entity-cache": []
}
\ No newline at end of file
{"ver":"1.0.1","uuid":"07c47af5-c5fc-4d7f-ad55-b30a06453b34","subMetas":{},"type":"prefab"}
import ScillaComponent from 'components/base/ScillaComponent';
import { Transform } from 'scilla-components/src';
import { gravityY } from './gameconst';
export default class BallItem extends ScillaComponent {
private _speed = 0;
private _speedY = 0;
onUpdate() {
const { entity } = this;
this._speed += 1.5;
entity.getComponent(Transform).position.y += this._speed;
console.log('BallItem onUpdate')
this._speedY += gravityY;
entity.getComponent(Transform).position.y += this._speedY;
}
bounceY(){
this._speedY *= -1;
}
}
\ No newline at end of file
......@@ -7,6 +7,7 @@ import { alien } from "../navigator/StackNavigator";
import { INavigatorViewBase } from "../navigator/VirtualNavigator";
import { Transform } from 'scilla-components/src';
import ScillaComponent from 'scilla-components/src/base/ScillaComponent';
import BallItem from './BallItem';
const GROUND_Y = 250; //碰到地板时,球的中心点的y
export default class ScenePlay extends ScillaComponent implements INavigatorViewBase {
......@@ -30,14 +31,14 @@ export default class ScenePlay extends ScillaComponent implements INavigatorView
}
onUpdate() {
// for (const ball of this.ballList) {
// ball.getComponent(Transform).position.y += 1;
// const y = ball.getComponent(Transform).position.y;
// console.log(ball.getComponent(Transform).position.y);
// if (y > GROUND_Y) {
// }
// }
for (const ball of this.ballList) {
const { position } = ball.getComponent(Transform);
console.log(position.y)
if (position.y > GROUND_Y) {
position.y = GROUND_Y;
(ball.getComponent(BallItem) as BallItem).bounceY();
}
}
}
onDidEnter(last: string, action: alien.NavigatorAction, parameters: any): void {
......
export const gravityY= 1.5;
\ No newline at end of file
......@@ -7083,6 +7083,27 @@
return Popup;
}(Component));
var gravityY = 1.5;
var BallItem = (function (_super) {
__extends(BallItem, _super);
function BallItem() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._speedY = 0;
return _this;
}
BallItem.prototype.onUpdate = function () {
var entity = this.entity;
this._speedY += gravityY;
entity.getComponent(Transform).position.y += this._speedY;
};
BallItem.prototype.bounceY = function () {
this._speedY *= -1;
};
return BallItem;
}(ScillaComponent));
var GROUND_Y = 250;
var ScenePlay = (function (_super) {
__extends(ScenePlay, _super);
function ScenePlay() {
......@@ -7099,6 +7120,25 @@
this.ballList = [];
};
ScenePlay.prototype.onUpdate = function () {
var e_1, _a;
try {
for (var _b = __values(this.ballList), _c = _b.next(); !_c.done; _c = _b.next()) {
var ball = _c.value;
var position = ball.getComponent(Transform).position;
console.log(position.y);
if (position.y > GROUND_Y) {
position.y = GROUND_Y;
ball.getComponent(BallItem).bounceY();
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_1) throw e_1.error; }
}
};
ScenePlay.prototype.onDidEnter = function (last, action, parameters) {
this.entity.getComponent(Transform).alpha = 1;
......@@ -7389,7 +7429,8 @@
registerDef('./scripts/popup/Popup', Popup);
registerDef('./scripts/scenes/ScenePlay', ScenePlay);
registerDef('./scripts/navigator/SingleSceneNavigator', SingleSceneNavigator);
registerDef('./scripts/dialogs/RulePanel', RulePanel);
registerDef('./scripts/dialogs/RulePanel', RulePanel);
registerDef('./scripts/scenes/BallItem', BallItem);
modifyEngineConfig({
lineHeightRatio: 1.2,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -49,3 +49,6 @@ registerDef('./scripts/navigator/SingleSceneNavigator', component13);
import component14 from '../../assets/scripts/dialogs/RulePanel';
registerDef('./scripts/dialogs/RulePanel', component14);
import component15 from '../../assets/scripts/scenes/BallItem';
registerDef('./scripts/scenes/BallItem', component15);
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