[RMXP] Having major heavy lag issues

Started by bigace, January 03, 2014, 03:21:42 am

Previous topic - Next topic

Heretic86

When I rewrote the XRXS Battle System, it started off very laggy because of the Gradient Bars.

The Gradient Bars were being drawn each and every frame, not when they changed.  The method I came up with to fix it wasnt great, but was part of a learning process.  What I did was only allow the bars to refresh or redraw if the Bars had changed at all.  That was done in the update method.  Check for any changes to the bars and refresh only as needed and as infrequently as possible. 

General advice:  Same thing goes with sprites in every scene.  Put a print inside the Refresh method right around contents.clear to see how frequently Refresh is being called.  Every frame, or only when a change is made?  print "Refreshing ", @event_id  Its annoying to be "Refresh Messaged", but gives a better idea where the engine is struggling.
Current Scripts:
Heretic's Moving Platforms

Current Demos:
Collection of Art and 100% Compatible Scripts

(Script Demos are all still available in the Collection link above.  I lost some individual demos due to a server crash.)

ForeverZer0

February 09, 2014, 09:16:25 pm #21 Last Edit: February 09, 2014, 09:17:45 pm by ForeverZer0
There is no reason a bitmap should ever be redrawn unless it has changed, anything else is wasted performance.
Convention is to use "update" to check if it needs changed, and if it does, it will cause call the "refresh" method that actually performs the drawing.

def update
 if @time.second != Time.now.second
   refresh_time
   @time = Time.now
 end
end

def refresh_time
 draw_some_stuff
end


You could of course choose to do whatever you like, but that is the logical manner that is traditionally followed.


I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.