Skip to content
Rafael Oliveira edited this page Feb 4, 2016 · 2 revisions

This page is outdated. The scene api was separated from Kha and now you can find it in the Kha2D library.

Scene

The Scene keeps track of all game objects at runtime. It handles an unrestricted amount of parallax scrolling tilemaps and sprites. The tilemaps are split up in two lists - backgrounds are drawn behind the sprites, foregrounds are drawn on top of the sprites. If a more complicated layout is needed, that includes multiple sprite layers, multiple Scenes can be created. Sprites are handled in three different lists (heroes, enemies and projectiles) to optimize the collision routines. Those lists can be used at will (heroes does not have to include real heroes), the specific names were only chosen, because they are fitting for most games. Only sprites in different lists can collide with each other.

Sprite

A Sprite is an autonomous graphics object which can be placed in a scene. In most games Sprites will be used to implement most of the game logic. Sprites by default have a collision box that corresponds to the used image, but this behavior can be customized, which is an important trick to optimize the gameplay especially in action games.

Animation

An animation is basically an array of indices into a sprite atlas which are played at a given speed. This is the most flexible way to achieve basic sprite animations, but it is made easy by means of convenient creation methods.

Tile

The tilemaps (levels created in the level-editor) are made up of a two-dimensional array of Tiles. The default Tile class just shows one tile and either does or does not collide. However Tile can easily subclassed to implement animated tiles or pixel perfect collisions. This can be seen in the TPlayer example game.

Clone this wiki locally