One way is to just spawn the objects in random positions and if the object collides with the player move it to a random position.
Here’s one possible example. Create it on the player, and repeatedly move it to a random position till it’s not touching the player.
On function “add spear”
— Create spear at (playerbox.x, playerbox.y)
— spear: overlaps playerbox
— — spear: set position to (random(windowWidth), random(windowheight))
Thanks for the answer! It's actually working, but i'm using an object with ScrollTo, so when using (random(windowWidth), random(windowheight)) isn't spawning in the place that i want. Instead it's possible to spawn through an specific area without it being an object or the window?
Or, if i need to use some sprite with a larger area that the spears will spawn on it (like making the spears spawning spreaded inside an invisible sprite box), how can i do that?