forked from PBS-KIDS/Platypus
-
Notifications
You must be signed in to change notification settings - Fork 0
Create an Entity
Derek Detweiler edited this page Nov 8, 2013
·
1 revision
To create an Entity, we create a JSON file and add it to the ‘entities’ section of the config.json file with the id that we want to refer to it by in the code as shown below:
"entities": [
{"id": "dirt", "src": "entities/dirt.json"},
{"id": "gem", "src": "entities/gem.json"},
]
Once we have this in place we can start editing the entity JSON file. Here we add the components that we want to make up the entity. Here is an example of an entity JSON file with two component definitions:
{
"id": "pickaxe",
"components":
[
{
"type": "collision-basic",
"shape": {
"offset": [0,-140],
"type": "rectangle",
"points": [ [-100,-140], [100,140] ]
},
"collisionType": "pickaxe"
},{
"type": "destroy-me",
"message": "prepare-for-collision",
"delay": 50
}
]
}
The types are the ids of the components from the game/config.json file. The other fields are passed in as the definition into the constructor of the components.
Platypus was developed by PBS KIDS and Gopherwood Studios. It is free to use (see licenses.txt), all assets in the example games are © Gopherwood Studios and/or © PBS KIDS.