Created
October 4, 2020 21:10
-
-
Save flushpot1125/fe78f6acc73553a5aceb2f5c3ddb64dd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//ball.ts | |
import { Mesh} from "@babylonjs/core"; | |
import GameComponent from "./game"; | |
export default class BallComponent extends Mesh { | |
public _scene: GameComponent; | |
//... | |
/** | |
* Called each frame. | |
*/ | |
public onUpdate(): void { | |
this.position.y = this._startHeight; | |
if (this.position.x < -30) { | |
this._scene.retry(); | |
} | |
} | |
//... | |
} | |
//game.ts | |
////..... | |
import { Scene } from "@babylonjs/core"; | |
export default class GameComponent extends Scene { | |
///... | |
/** | |
* THe player lose, let's retry :) | |
*/ | |
public retry(): void { | |
// do something.. | |
///... | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment