GML Text cropping ?

Rackover

Member
Hello,

I'm trying to draw text in a way that it will be partially trimmed (top and bottom), gradually unveiling itself until readable : then after a certain amount of time, untrimming itself in a smooth animation.

The problem is with text-cropping. I saw somewhere that you could scale text with draw_text_transformed, but this is not what I want.

Here is what I'm looking for.

From this...


...to this.


Is it possible in any way ?

Regards,
Rackover
 

obscene

Member
Draw it onto a surface and then use draw_surface_part to open it up.

Surfaces can be a little tricky if you're new to them to search Youtube for a tutorial on them.
 

hippyman

Member
If you're drawing the text with sprites you can avoid using surfaces and just use draw_sprite_part as well. But if you're drawing the text with any of the draw_text functions than surfaces will be required like obscene said.

EDIT: Oops I'm dumb and didn't see that you already mentioned you're using the draw_text functions. Obscene nailed it.
 

Rackover

Member
Thank you!
I've read the surface documentation but I'm completely lost. Is there any good tutorial about the surfaces out there ?
 

hippyman

Member
Once you figure them out they're really simple.

The simplest way to explain it is like this.

You're always drawing onto a surface with just normal drawing. That's called the application_surface.

You create a surface which is just an empty canvas with surface_create which returns your surface ID.
Then you need to set the draw target with surface_set_target(YourSurface) where YourSurface is the surfaceID returned from surface_create
Then draw all the stuff you want onto the surface just like you normally would.
Once you're done drawing, use surface_reset_target() so that GM will draw on the application_surface again.
Then you actually draw your surface to the screen.

I'd still recommend following Obscene's advice and google it to find some tutorials that go more in depth. They're volatile resources which isn't bad but something you'll need to manage. Reading the documentation and following some tutorials should shed some light on that.
 
Top