-
Notifications
You must be signed in to change notification settings - Fork 0
Class GameObject
Moderr edited this page Feb 28, 2023
·
3 revisions
class GameObjectBase class for creating game objects in game.
Constructs new GameObject with given parameters.
Params:
number x - X-coordinate (Default: 0)
number y - Y-coordinate (Default: 0)
number wdith - Width on the grid (Default: 0)
number height - Height on the grid (Default: 0)
class ExampleGameObject extends GameObject{
OnStart(gameManager) {
}
OnDestroy(gameManager) {
}
Update(deltaTime, gameManager) {
}
OnDraw(renderer, gameManager) {
}
FixedUpdate(deltaTime, gameManager) {
}
OnMouseClick(pos, gameManager) {
}
}
// game.addGameObject(new ExampleGameObject());| Method | Description |
|---|---|
| OnStart(gameManager) | Method invoked at object initialization in game. |
| OnDestroy(gameManager) | Method invoked before destroying object. |
| Update(deltaTime, gameManager) | The first method called every frame if the GameObject is enabled. |
| OnDraw(renderer, gameManager) | Method invoked at game loop when objects are drawing if the GameObject is enabled. |
| FixedUpdate(deltaTime, gameManager) | The last method called every frame if the GameObject is enabled. |
| OnMouseClick(pos, gameManager) | Method invoked when GameObject is clicked. |
| Method | Description |
|---|---|
| move(x, y) | Moves GameObject with given parameters. |
| goTo(x, y) | Sets position of GameObject to position given in parameters. |
| getId() | Gets the unique ID. |
| isEnabled() | Gets is enabled. |
| getName() | Gets the name of GameObject. |
| getTag() | Gets the tag of GameObject. |
| getSortingOrder() | Gets the sorting order of GameObject. |
| getWidth() | Gets the GameObject width. |
| getHeight() | Gets the GameObject height. |
| getX() | Gets the X-coordinate of position. |
| getY() | Gets the Y-coordinate of position. |
| getVector2() | Gets the Vector2 of position. |
| setEnabled(value) | Sets enabled. |
| setName(value) | Sets new name. |
| setTag(value) | Sets new tag. |
| setSortingOrder(value) | Sets new sorting order. |
| setWidth(value) | Sets new width. |
| setHeight(value) | Sets new height. |
W.I.P