I'm new to surfaces but I need to use them to prevent lag.
But, I can't get them to work. Are the only commands you need these:surface=surface_create(50,100)surface_set_target(surface)surface_reset_target()draw_surface(surface,0,0)Also, do you just leave the object's draw events just where they are?I don't know if what I am doing is actually doing is working at all, as my game still lags.Ask if you need more to answer my question, as I don't really know what to post and I'm not going to post my source. =PCredit if wantedSo, I think I'm doing it wrong.EDIT: I think the problem I had in the picture was that I also had 485 surfaces, which I didn't know was possible.
Use draw_surface in the draw event.
Like this:
Create Event:surf = surface_create(room_width,room_height);surface_set_target(surf);draw_clear(c_gray);draw_text(10,10,"Surfaces!");surface_reset_target();Draw Event:draw_surface(surf,0,0);You've already posted your source. Would you like me to fix it for you or would you rather sit around following a shred of some blame. If you want to reduce lag, you can easily just work on deactivating or something. But I haven't trespassed, so I can't really help you
I've noticed a reduce of lag sometimes when I draw on surfaces in the step event and draw them in the draw event.
…?Well the idea of using a surface is to draw all your static objects with it. In my case I would send the surface to a background and just set it as the room's background, for the tile map area in my editor. You may want to do something else instead of using objects unless collisions are involved, if that is so then you can make the objects invisible and have their images drawn on the surface, preferably handled by one object. You may even want to create an array like
object_handle(index,0) = xobject_handle(index,1) = yobject_handle(index,2) = image_namewhen the object is placed, and have an object process that data to draw out the surface.If thats not too confusing I'll try harder..What I would do:
create a 2-dimensional array/ds_grid containing the data for each cell.- create a surface as large as the screen- when you click, you draw the correct block on the surface, and set the array/grid- when you destroy something, you draw a black rectangle on the surface, and set the array/grid- in draw event you draw the surface- to generate the level you read from the grid/arrayFor animation you could use objects for the animating blocks.
You could only draw objects in the view. That might help.
Have you tried more conventional means of optimisation before using surfaces? Just setting "visible = false" for objects outside the window can yield speed improvements without needing to rely on the VRAM.
Ya, don't take some random point of advice as a holy grail