Game

class Game(val filePath: String, val resources: Resources) : AbstractParentOrGame

The root node of a game's tree of resources. Each node in this tree implements the Resource interface.

A Game is saved as a .kyd file which uses a JSON format.

Constructors

Link copied to clipboard
constructor(filePath: String, resources: Resources)

Properties

Link copied to clipboard
open override val children: MutableObservableMap<String, Resource>
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val name: String
Link copied to clipboard

The size of window we will try to create when the game starts. The actual window size may be larger or smaller.

Link copied to clipboard
open override val parent: Nothing?
Link copied to clipboard
val pickGroups: MutableObservableList<PickGroup>

This is only needed in the editor, not during game-play. Each PickGroup contains a list of items which can be picked and dropped onto a stage, creating an Actor.

Link copied to clipboard

A map of old-paths to new-paths. When resources are renamed, we remember this old path and map it to its new path. Later, acts can be loaded, and any references to old-paths can be fixed, and the act saved. This map can then be cleared.

Link copied to clipboard
val resources: Resources
Link copied to clipboard
open override val resourceType: ResourceType
Link copied to clipboard
Link copied to clipboard

Describes how the Stages are arranged. In a very simple game, there is only 1 StageDescription (with a default name of main). However, more complicated games may have many stages, stacked on top of each other. For example, we may have a bottom layer (index==0) which only contains terrain. Then a middle layer (index==1) for most of the active Actors. Then a layer above that for Actors which are always above the active layers. Maybe this is used for special effects etc.

Link copied to clipboard
Link copied to clipboard

Where the center of world is relative as a proportion to the window's size. e.g. (0.5,0.5) will make world point (0,0) appear in the middle of the window. (0,0) will make world point (0,0) appear at the top left of the window.

Functions

Link copied to clipboard
open override fun add(child: Resource)
Link copied to clipboard
fun createStage(stageName: String): Stage
Link copied to clipboard
open override fun dangerousRename(newName: String)
Link copied to clipboard
open fun find(path: String): Resource?
Link copied to clipboard
Link copied to clipboard
open override fun findChild(name: String): Resource?
Link copied to clipboard
open fun findUnresolved(path: String): Resource?
Link copied to clipboard
open override fun game(): Game
Link copied to clipboard
open override fun path(): String
Link copied to clipboard
open override fun pathWithTrailingSlash(): String

Similar to path, but it also includes a trailing path. This is useful when building descendant paths as there is no special case needed for the root Game.

Link copied to clipboard
open override fun remove(child: Resource)
Link copied to clipboard
open override fun rename(child: Resource, newName: String)
Link copied to clipboard
fun resolvePath(path: String, relativeTo: Resource = this): String
Link copied to clipboard

Called immediately after a game is loaded from a .kyd file. It ensures that Resources such as Pose which link to other Resources are linked. In the case of Pose, its graphicPath is used to find the appropriate Graphic.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun walkTree(onVisit: (Resource) -> Unit)