Home | Customize | Blog | Extras | Log In | Info
Manual | D&D icons | GML Parser | Archive | Iso City
Username: Password:  
About | Features | Directory | Banners | Contact

Designing Games with GameMaker
Designing Games with GameMaker

Drawing sprites and backgrounds

Objects normally have a sprite associated to it that is drawn. But you can use the draw event to draw other things. This section and the next couple give you information on what is possible. First of all, there are functions to draw sprites and backgrounds in different ways. These give you more control over the appearance of the sprite. Also you can draw (parts of) backgrounds.

draw_sprite(sprite,subimg,x,y) Draws subimage subimg (-1 = current) of the sprite with its origin at position (x,y). (Without color blending and no alpha transparency.)
draw_sprite_stretched(sprite,subimg,x,y,w,h) Draws the sprite stretched so that it fills the region with top-left corner (x,y) and width w and height h.
draw_sprite_tiled(sprite,subimg,x,y) Draws the sprite tiled so that it fills the entire room. (x,y) is the place where one of the sprites is drawn.
draw_sprite_part(sprite,subimg,left,top,width,height,x,y) Draws the indicated part of subimage subimg (-1 = current) of the sprite with the top-left corner of the part at position (x,y).
draw_sprite_ext(sprite,subimg,x,y,xscale,yscale,rot,color,alpha) Draws the sprite scaled with factors xscale and yscale and rotated counterclockwise over rot degrees. color is the blending color (use c_white for no blending) and alpha indicates the transparency factor with which the images is merged with its background. A value of 0 makes the sprite completely transparent. A value of 1 makes it completely solid. This function can create great effect (for example partially transparent explosions).

draw_background(back,x,y) Draws the background at position (x,y). (Without color blending and no alpha transparency.)
draw_background_stretched(back,x,y,w,h) Draws the background stretched to the indicated region.
draw_background_tiled(back,x,y) Draws the background tiled so that it fills the entire room.
draw_background_part(back,left,top,width,height,x,y) Draws the indicated part of the background with the top-left corner of the part at position (x,y).

The following functions are extended functions of the ones indicated above. These extended versions can not be used in the Lite Edition!

draw_sprite_stretched_ext(sprite,subimg,x,y,w,h,color,alpha) Draws the sprite stretched so that it fills the region with top-left corner (x,y) and width w and height h. color is the blending color and alpha indicates the transparency setting.
draw_sprite_tiled_ext(sprite,subimg,x,y,xscale,yscale,color,alpha) Draws the sprite tiled so that it fills the entire room but now with scale factors and a color and transparency setting.
draw_sprite_part_ext(sprite,subimg,left,top,width,height,x,y,xscale,yscale,color,alpha) Draws the indicated part of subimage subimg (-1 = current) of the sprite with the top-left corner of the part at position (x,y) but now with scale factors and a color and transparency setting.
draw_sprite_general(sprite,subimg,left,top,width,height,x,y,xscale,yscale,rot,c1,c2,c3,c4,alpha) The most general drawing function. It draws the indicated part of subimage subimg (-1 = current) of the sprite with the top-left corner of the part at position (x,y) but now with scale factors, a rotation angle, a color for each of the four vertices (top-left, top-right, bottom-right, and bottom-left), and an alpha transparency value. Note that rotation takes place around the top-left corner of the part.
draw_self() This command is exactly the same as draw_sprite_ext() except it will use the instances own variables to draw itself (x,y, scale, angle etc.) This provides the same action as if the instance was draw without a script.

draw_background_ext(back,x,y,xscale,yscale,rot,color,alpha) Draws the background scaled and rotated with blending color (use c_white for no blending) and transparency alpha (0-1).
draw_background_stretched_ext(back,x,y,w,h,color,alpha) Draws the background stretched to the indicated region. color is the blending color and alpha indicates the transparency setting.
draw_background_tiled_ext(back,x,y,xscale,yscale,color,alpha) Draws the background tiled so that it fills the entire room but now with scale factors and a color and transparency setting.
draw_background_part_ext(back,left,top,width,height,x,y,xscale,yscale,color,alpha) Draws the indicated part of the background with the top-left corner of the part at position (x,y) but now with scale factors and a color and transparency setting.
draw_background_general(back,left,top,width,height,x,y,xscale,yscale,rot,c1,c2,c3,c4,alpha) The most general drawing function. It draws the indicated part of the background with the top-left corner of the part at position (x,y) but now with scale factors, a rotation angle, a color for each of the four vertices (top-left, top-right, bottom-right, and bottom-left), and an alpha transparency value. Note that rotation takes place around the top-left corner of the part.

Search Search


Alternative versions Alternative versions

You can also read this manual on one single long page (± 1.5 mb)

Also available in: Dutch French German

ZIP Download helpfile

Advertisement Advertisement

GameMaker Manual