For better imagination. I want create block with (for exam.) black-border and inside will be another color. And when my actor hit this block. Actor will stop fall down.
Or second option, when my actor will fall to ANY picture, how to make it, to stop fall down?
If the block is an actor, you can do it like this:
- move the player down
- if it is touching a block
--- move it back / move it up until it doesn't touch a block anymore
If the block is just a part of the background and no actor, you can do the same thing but instead of touching you need to compare the color of the background to the location of the actor after moving.
It's bad idea, when u have function for fall down and then move it up... or no? U can do it better, when u will use function for control - if he will fall or not fall down. And i just don't know syntax, how to write it to my code. :) I am newbee
No, you wouldn't see it. You only see the actor at its location after the whole act method (in fact, the act methods of the active world and all actors inside them). So for example if your act method looks like this:
I know what i want to do. (I want make gravity = false, when he step on any block). But i don't know of this function, how to write it...
IN PROCESS:
-Actor(player) will step on Actor(block)
-gravity = false
-Actor(player) will be able to move right/left.
And now i just need syntax-code of-> if under actor(player) is specific block <-
It is not stupid and it is not useless.
If your actor is not moving only one cell per act, there is a chance that it ends up in the middle of the block. Then you need to move it outside the block again. The alternative would be to check all cells between the current cell and its target cell and if there is a block, you can directly calculate where the actor would touch the block and move it there. But that has the same result, but is far more complex.