Skip to content

Object Files

Dev Kev edited this page Aug 10, 2021 · 1 revision

This term might be a bit confusing. In the context of this engine, an object is not a java file or java object. Objects in Pixxel are all props used to decorate your world. Even the player is an object!

Object files provide the so called "root object" data.
In the root object, you define a static data by setting it's values like texture, size etc.
Those values are passed into a "world object", when an object is then added to the world.
World Objects hold the root object information but also aditionally values like position and changes.
Those world objects are then saved in the world file. So don't worry too much about them.

Is is important to understand this section and all the properties, because you will have to create root objects manually by adding theese type of files to the game.json. There are a lot of techniques and uses to provide root objects.
Few examples should give you an idea what's possible.
Root Object Files are simple JSON files.
You can find some example objects here:

/android/assets/local/Demo/

Example for the most basic object:

{
  "loadType": DEFAULT,
  "id": "torch-item",
  "texturePath": "*/torch-dark.png",
  "size": {
    "x": -0.7,
    "y": -0.7
  }
}

Example for multiple objects in a single file loaded using a tileset:

{
  "id": "tileset",
  "texturePath": "*/dungeonwalls.png",
  "loadType": "TILESET",
  "tX": 0,
  "tY": 0,
  "tW": 24,
  "tH": 24,
  "size": {
    "x": -1,
    "y": -1
  }
}

Properties

"id"

The id of the specific root object.
Every object should have it's own, unique id. If a file causes multiple objects to load (like tilesets) Unique id's are generated.


"texturePath"

The path to the texture of the object. Usually a .png or .jpg file. Root directory for assets is /assets/.
To load textures with a path relative to the path the object file is in, use a */ at the start:
*/texture.png This path would represent a .png file in the same directory as the object file.


"loadType"

The type of the object. The following values are accepted, otherwise DEFAULT is being used:

  • DEFAULT Default object loading
  • Home
  • Getting Started
    • Opening the project
    • Android SDK
    • Java version
    • Dependencies
  • Level Editor
    • Modifying and adding objects
  • Structure
    • The Main class
    • How thie engine works
    • Creating Behaviors
    • Behavior Examples
  • File system
  • Script
    • Syntax
    • Command line
    • Where to use the script
    • Creating custom commands

Clone this wiki locally