Skip to content

Objects

Mighty Pancake edited this page Apr 7, 2020 · 2 revisions

What is a pancake object?

Pancake object is part of data that you give to pancake so it can simulate things about this object. For example, you can create an object named player and give it animation/static image, apply physics to it, define if it should collide, etc.

Object's attributes

Here are the values that every pancake object should have:

  • x <- horizontal coordinate of the object. Combined with "y", it defines the position of the object. This defines where the left edge of an object should be.

  • y <- vertical coordinate of the object. Combined with "x", it defines the position of the object. This defines where the top edge of an object should be.

  • width <- the width of the object. It's used for collision and such.

  • height <- the height of the object. It's used for collision and such.

Here are some parameters that are optional:

  • colliding <- Tells if the object should collide with other objects with colliding set to true. If it's not set to anything, it will act as if it's false.

  • name <- This tells pancake what name the object should have. It's very important when you want to animate the object using pancake's built-in animation system

  • image <- This defines what image should be displayed for this object. Remember, it is a string containing the name you've given the image while adding it using pancake.addImage. If the object has no image set, it will be invisible, but will still collide and act as it was there!

  • layer <- Defines what layer the object should be in. For more on how layers work, visit https://github.com/pancake-library/pancake/wiki/layers

Other (less important):

Physic attributes

It's advised to use pancake.getStat(object, attribute_nam) to get a parameter that is related to physics such as friction, velocity, acceleration, mass or direction! For more information visit: https://github.com/pancake-library/pancake/wiki/pancake.getStat

How to add an object?

For this, see https://github.com/pancake-library/pancake/wiki/pancake.addObject

Clone this wiki locally