Solarus-Games English Forum

Solarus => Development => Topic started by: The Pink Bunny on June 23, 2016, 03:51:15 PM

Title: Same Movement on Different Entities? (and 'on_obstacle_reached()' question)
Post by: The Pink Bunny on June 23, 2016, 03:51:15 PM
Can movements only be applied to one entity at a time? I'm trying to have two entities make the same movement a bit delayed from each other, but when the second movement starts, the first just stops. I know I can fix that by just making another movement, but that seems like strange behavior to me. Is that intentional?

edit: Since this question is more trivial than practical (and I don't want to start two threads in a row), I'll also ask this here: Is there a difference between 'entity:on_obstacle_reached(movement)' and 'movement:on_obstacle_reached()' ?
Title: Re: Same Movement on Different Entities? (and 'on_obstacle_reached()' question)
Post by: Diarandor on June 23, 2016, 04:58:25 PM
I guess this is intentional since otherwise some functions and events, like get/set_xy and on_obstacle_reached, would have no sense for several entities at the same time. If you still need help to do something with movements, then just explain a bit what you are trying to do :).

For the last question: yes and no. Both functions are called when an obstacle is reached, but as you know they are defined on different entities. So, depending on if you need the event to be called always or only for the current movement (when an obstacle is reached), you should use the corresponding one. The event defined on the movement will be destroyed when the movement does, obviously. Do not worry to ask, even if it seems something silly, because it is not.

In this case, I think it should be said explicitly in the API that a movement can be attached, at most, to only one entity.