posted 9 years ago
This might get really confusing really fast so I'll do my best to be clear but I apologize in advance if I fail in communicating clearly.
I have a game with two frames: GameFrame and BrushToolBox. GameFrame has a canvas called GameCanvas while BrushToolBox has a canvas called ObjectPainting. Each of these canvases are created using their own class that extends canvas.
GameFrame is the main class of the project which, when a button called LevelEditor is pressed, will create BrushToolBox.
I am getting a very big problem with performance and sprite drawing. If ObjectPainting draws an image before GameCanvas has drawn its first image then GameCanvas will fall to 15 frames per second (instead of the normal 60 fps) when it's drawing images. If GameCanvas draws an image before ObjectPainting has drawn its first image then there is never a performance drop but ObjectPainting will not draw any images. Both canvases use their own drawing methods, that is neither of the canvases use an overridden method for drawing.
This is the entire ObjectPainting class (without includes):
And this is the relevant portion of the GameCanvas class (without includes):