Skip to content

Instantly share code, notes, and snippets.

@flushpot1125
Created October 4, 2020 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flushpot1125/fe78f6acc73553a5aceb2f5c3ddb64dd to your computer and use it in GitHub Desktop.
Save flushpot1125/fe78f6acc73553a5aceb2f5c3ddb64dd to your computer and use it in GitHub Desktop.
//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