1

Dear Stackoverflowers,

I am currently trying to remake my own age of empires game in javafx. I have made a "Tree" Class which extends a "Resource" Class which extends a "Sprite" Class which extends the javafx.scene.layout.Region class. After adding roughly 2000 Tree objects the game will start running noticably less smoother.

If anyone has any suggestions on how to make it more efficient, I'd love to hear it.

  • It's hard to suggest how to optimize without [seeing the code](http://stackoverflow.com/help/mcve). Perhaps review the [openjfx Performance tips and tricks](https://wiki.openjdk.java.net/display/OpenJFX/Performance+Tips+and+Tricks). Without further information, I'd suggest that this question is a duplicate of [What is the best way to display millions of images in Java?](http://stackoverflow.com/questions/14467719/what-is-the-best-way-to-display-millions-of-images-in-java) or [JavaFX 2 drawing performance](http://stackoverflow.com/questions/10506637/javafx-2-drawing-performance) – jewelsea Mar 25 '16 at 16:41
  • i must admit i only spent around 10 minutes searching for a similar question. I don't know what stackoverflow users like best, should i remove this topic or keep it so that others can see your links too? – couragous cucumber Mar 25 '16 at 18:18
  • I'll vote to close it as a duplicate. – jewelsea Mar 25 '16 at 18:43

1 Answers1

0

You might consider switching caching on for your trees. This is discussed here:

How do setCache() and CacheHint work together in JavaFX?

On the other hand you might ask yourself why you need such a heavy structure for your trees. Can't you just use a set of images?

Community
  • 1
  • 1
mipa
  • 10,369
  • 2
  • 16
  • 35