How to copy an image of the Code Editor in your program!
-
HI,
I know that some people were curious about how I managed to achieve the effect of having the code editor split apart at the beginning of my Game Jam project, The Growing Pains of Señorita Space Worm. So here is how I did it:
Note that in order for this to work in both handheld and docked, there must be no
SetMode()
call made before this. You can always do that immediately afterwards if you want to.This must also be done before any calls to
clear()
orupdate()
.So, the actual code that captures the image is just one row:
screenGrab = copyImage(framebuffer, {0, 0, gWidth(), gHeight()})
Now, the image of the editor is stored in the screenGrab variable and you can use it as any other image.
For example, to achieve the effect of the editor splitting and moving apart, I just do the following:
for t = 0 to gWidth() / 2 step 5 loop drawImage(screenGrab, {0, 0, gWidth() / 2, gHeight()}, {-t, 0, gWidth() / 2, gHeight()}) drawImage(screenGrab, {gWidth() / 2, 0, gWidth() / 2, gHeight()}, {t + gWidth() / 2, 0, gWidth() / 2, gHeight()}) repeat
This draws the left part of the image on the left side of the screen with a (-t) offset, and the right part of the image on the right part of the screen with a t offset.
-
thanks so much this will be useful!