Animated falling block ?

Started by FacciaBianca, September 27, 2017, 01:23:24 PM

Previous topic - Next topic
Hello everyone~

I've been making a "push-block-to-switch" puzzle in Solarus, along with a script which creates another block after you've pushed it in a hole, then re-entered the room.

However, it appears that when I push said block in a hole, it immediatly disappears halfway between the ground and the ravine.

So, I've been wondering if I needed to create the rest of the block's moving and falling animation, or if I did something wrong. Of course, I can provide the script if required !

In advance, thank you very much and have a nice day.

A solution can be to create an animation using a new entity, right after the block disappears. It can be a custom entity with the sprite animation you need.

September 27, 2017, 02:17:53 PM #2 Last Edit: September 27, 2017, 02:31:41 PM by FacciaBianca
Thanks a lot for answering Christopho, I'll do that, however I'm trying to figure out which method/event would allow me to get the position of the hole in which the block falls/disappears, so that it would create the animation wherever it should be happening. (I'm a newbie in lua, so I'm quite toying with anything that could work according to my own "logic" ^^)

Edit : or maybe that could be done with sensors ? Nevermind, I think that only works with the hero.

You can use the event block:on_moving() or block:on_moved() and detect the ground below the block to know if it is a hole.

Do what Chris says. You only need to define the events once, for the block metatable.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

(Sorry for the late answer, I prefer trying to fix things myself before asking for help.)

Quote from: Diarandor on September 27, 2017, 04:04:05 PM
Do what Chris says. You only need to define the events once, for the block metatable.
Alright I'll do this. Though am I brainstorming too much, or does it actually work with local variables ?

To keep things simple, I'd start by making it local to the one block you want to make fall.
And only later do some refactoring with metatables to make the code reusable.

Thank you both for helping out. Now that I think about it, I should have named this thread "Animated falling vase/item/enemy", since this kind of block I'm using normally can't be pushed into holes unlike blocks created by the Cane of Somaria.