I’m working on a little Tower Defense game, but whenever I hit the spawner (top middle) it always spawns in the top left no matter what I do. also you can click and drag the towers around.
I’m kind of confused on what is going on.
The spawn behaviors will automatically spawn objects at location 0,0. Since you don’t have anything to indicate a location, such as a custom cursor, that is why they are spawning there.
And the camera is a bit confusing and hard to click on anything. I would recommend a click and drag style camera or something that can be moved around using arrow keys.
Here is an example I had made that would help demonstrate a grid style area, cursor, and click and drag camera, which I think would help a lot for any tower defense style games.
yeah sorry about that, my labtop died in the middle of messing with the screen movement thanks. also I thought that’s what the coordinates you put in in spawn do?
The level editor is essentially a grid, like you can place objects and such.
Each grid space is 32 by 32 pixels. The X and Y input of a spawn will determine where at in the level the object will be spawned at. By default, it’s automatically set at X=0 and Y=0 so it spawns in the top left corner which is where 0,0 is located in the editor.
So, if you want it to spawn at 1,1 in the game, you want X=32 and Y=32. Then you multiply 32 by whatever the grid location is.
Your best bet is to have a cursor or something that you can extract the location from, which can automatically locate itself by pixels, so you don’t have to multiply 32 by anything. And by doing this, you can choose where you place towers within the game.
This example still works, but I’m currently trying to add a feature where you can add a border, since it originally didn’t have that. So, you don’t infinitely wander off the screen.
see this for some ideas
This game has better and drag and drop features if you’re aming for that.