Skip to content
Download

Objects without code

You want a floor, a wall or a spike: things that just sit still in the level. They don’t need code.

In Recursos (Resources), right-click a folder and choose Novo objeto (sem código)… (new object, without code). The object is created with the data only: sprite, Sólido (solid), mask, physics and everything else in the Inspector.

Drag it into the room like any other object.

An object without code has no class, so you can’t write onCollide<Espinho>. Use the object’s name in quotes:

void Player::onSpawn() {
onTouchStart("Espinho", [this](Entity&) { restart(); });
}

The functions that take the name:

To Functions
Know whether it touches touching("Espinho"), collidesAt("Espinho", x, y + 1), findAt("Espinho", x, y)
React to contact onCollide("Espinho", ...), onTouchStart("Espinho", ...), onTouchEnd("Espinho", ...)
Count and loop count("Moeda"), any("Moeda"), each("Chao", ...), destroyAll("Moeda")

They also work for objects that have a class.

To keep the player from going through an object, just check Sólido on it: moveAndStop and placeFree already respect every solid, with or without code.

An object without code has no events and no variables in the code. If it needs to move, count time or keep a value, create it with Novo objeto… (new object).