Hi! I made my game so that objects spawn on the screen in random places, within a certain rectangle. How do I make the objects spawn in the same random places of this rectangle, except for certain small areas where I have water or fire, for example? I’ve used collisions, but it’s not very pretty.
What do you mean not very pretty?
Can you give a screen shot as an example of what you mean? And a screen shot of your events that spawn the objects.
The spawn object appears in a forbidden place for a short time, and only then appears in a permitted place
You can rework your spawn object to use a invisible sprite to check for collisions first.
If sprite is colliding with kamen2 or water, change its X and Y position.
Below that should be your normal spawn object event.
What you are doing is checking the collision once per frame. You should check for a collision and reposition in a loop, until there is no longer a collision, so it happens in one frame. This will prevent the object appearing in a forbidden position for a short period of time.
First place the object, and then using a while the collision is true, change the position of the object.
First event places the object. Then in the second event the while repositions it while it’s in collision with another object.
My first 3 thoughts are:
- Put all the objects the food1 can collide with into an object group, and check for collision with that group name.
- you have 2 tweens with the same name on an object, and you didn’t remove the first tween before you started the second.
- That delay between the colour tweens may be having an impact. I suggest you remove the wait and the second tween. Instead, have a standalone event that checks if the object tween has finished, and in the actions removes it and starts the second one:
How difficult it all is for a beginner. I will study it. Thank you very much for your attention to my problem)
The problem was due to the improper use of the twin. Now everything is beautiful. You’re a genius!