Place actor on touch. How can I prevent overlap?
ewout_timmer@hotmail.com
Member Posts: 1
I've got an actor set up so when I touch the screen it will be placed on screen and immediatly snaps to grid.
change attribute self.position.X to (floor( self.Position.X /64)*64)+32. The same goes for Y.
I also added a timer so I can draw a path with the tiles. But this results in numerous tiles being placed on top of each other.
Once a tile is placed on the screen I don't want to be able to place another tile (same actor) on top of it.
Is there anyway to do this? All my attempts lead to nothing or the wrong tiles being destroyed.
Answers
go to the tile drag a collide and say bounce when colliding with actor of type tile
hope it helps
Jarritos
If you use a table to keep track of what's in each "tile" of the grid, you should be able to test to see if something is already occupying the space and then disable the drop...
Alternately... check collision... and if so, then make the X or Y (or both) to + (floor( self.Position.X /64)*64)+32 (the next tile over). Of course, you might run into that being occupied as well.
you're better off keeping track with a table, then you will always know if there is a free tile nearby.