Risorse – Background

Le funzioni seguenti forniscono informazioni su uno sfondo:

background_exists() ind Dato l’indice di un sottofondo restituisce: esiste?, il nome, la larghezza, l’altezza, trasparente?, smoothed?, preloaded?
background_get_name() ind
background_get_width() ind
background_get_height() ind
background_get_transparent() ind
background_get_smooth() ind
background_get_preload() ind

In alcune situazioni potresti voler salvare su file la bitmap corrispondente allo sfondo.

Per questo puoi utilizzare la funzione seguente:

background_save ind
fname
Standard Edition
Salva lo sfondo ind sul file fname.
Deve essere un file .png.

 

Modificare sfondi

The following routines can be used to create new backgrounds and to remove them.

background_duplicate(ind) Creates a duplicate of the background with the given index. It returns the index of the new background. When an error occurs -1 is returned.
background_assign(ind,back) Assigns the indicated background to background ind. So this makes a copy of the background.
background_add(fname,removeback,smooth) Adds the image stored in the file fname to the set of background resources. Many different types of images can be dealt with. When the image has an alpha channel, this is used for transparency. removeback indicates whether to make all pixels with the background color (left-bottom pixel) transparent. smooth indicates whether to smooth the boundaries. The function returns the index of the new background that you can then use to draw it or to assign it to the variable background_index[0] to make it visible in the current room. When an error occurs -1 is returned.
background_replace(ind,fname,removeback,smooth) Same as above but in this case the background with index ind is replaced. The function returns whether it is successful. When the background is currently visible in the room it wil be replaced also.
background_add_background(fname) Adds the background stored the file fname to the set of background resources. The file must be a .gmbck file that is saved in the background property form in GameMaker. As this file contains all background settings, no further arguments are required. The function returns the index of the new background that you can then use to draw it or to assign it to the variable background_index[0] to make it visible in the current room. When an error occurs -1 is returned.
background_replace_background(ind,fname) Same as above but in this case the background with index ind is replaced. The function returns whether it is successful. When the background is currently visible in the room it wil be replaced also.
background_create_color(w,h,col) Creates a background of the given size and with the given color. It returns the index of the new background. When an error occurs -1 is returned.
background_create_gradient(w,h,col1,col2,kind) Creates a gradient filled background of the given size. col1 and col2 indicate the two colors. kind is a number between 0 and 5 indicating the kind of gradient: 0=horizontal 1=vertical, 2= rectangle, 3=ellipse, 4=double horizontal, 5=double vertical. It returns the index of the new background. When an error occurs -1 is returned.
background_create_from_screen(x,y,w,h,removeback,smooth) Creates a background by copying the given area from the screen. removeback indicates whether to make all pixels with the background color (left-bottom pixel) transparent. smooth indicates whether to smooth the boundaries. This function makes it possible to create any background you want. Draw the image on the screen using the drawing functions and next create a background from it. (If you don’t do this in the drawing event you can even do it in such a way that it is not visible on the screen by not refreshing the screen.) The function returns the index of the new background. A work of caution is required here. Even though we speak about the screen, it is actually the drawing region that matters. The fact that there is a window on the screen and that the image might be scaled in this window does not matter.
background_create_from_surface(id,x,y,w,h,removeback,smooth) Creates a background by copying the given area from the surface with the given id. removeback indicates whether to make all pixels with the background color (left-bottom pixel) transparent. smooth indicates whether to smooth the boundaries. This function makes it possible to create any background you want. Draw the image on the surface using the drawing functions and next create a background from it. Note that alpha values are maintained in the background.
background_delete(ind) Deletes the background from memory, freeing the memory used.

The following routine exists to change the appearance of a background.

background_set_alpha_from_background(ind,back) Changes the alpha (transparancy) values in the background with index ind using the intensity values in the background back. This cannot be undone.

Lascia un commento