Original Post
Hello, thank you for taking time to look at my topic.
I recently started learning Java and wanted to build a game engine with it. I can handle most of the general programming but there are some basic game-building techniques that aren't very straightforward for me yet.
I started programming games in Game Maker, which has built-in functions for deleting objects and drawing sprites very easily. As it turns out though I have to build those functions from scratch in Java. I don't have any problems with that (allows for greater freedom and functionality) but I would need a bit of help to get me started on this.
So my questions is:
What is the proper way of removing/deleting objects in your game?
In Game Maker, you would just type out a function like "instance_destroy(object_name)" and -poof-, object is gone. In Java, I haven't really been able to find a proper function that does exactly that. I did find some things about 'disposing' things and that 'garbage collector' thing but that does not really make sense to me yet. Is that the way to go? Alternatively, I heard that the proper way to do this is to initially make a batch of objects and while the game is running, assigning (sub-)classes to them later on. If you would want to 'delete' them you just simply exclude them from the drawing phase and such. Sounds strange, but might work.
So what do you think? I would really appreciate any help, thank you! =)
I recently started learning Java and wanted to build a game engine with it. I can handle most of the general programming but there are some basic game-building techniques that aren't very straightforward for me yet.
I started programming games in Game Maker, which has built-in functions for deleting objects and drawing sprites very easily. As it turns out though I have to build those functions from scratch in Java. I don't have any problems with that (allows for greater freedom and functionality) but I would need a bit of help to get me started on this.
So my questions is:
What is the proper way of removing/deleting objects in your game?
In Game Maker, you would just type out a function like "instance_destroy(object_name)" and -poof-, object is gone. In Java, I haven't really been able to find a proper function that does exactly that. I did find some things about 'disposing' things and that 'garbage collector' thing but that does not really make sense to me yet. Is that the way to go? Alternatively, I heard that the proper way to do this is to initially make a batch of objects and while the game is running, assigning (sub-)classes to them later on. If you would want to 'delete' them you just simply exclude them from the drawing phase and such. Sounds strange, but might work.
So what do you think? I would really appreciate any help, thank you! =)