Comunidad Game Maker

Ayuda => Preguntas y respuestas => Mensaje iniciado por: Ciberman en Enero 17, 2012, 04:15:35 AM

Título: Aclarar una imagen
Publicado por: Ciberman en Enero 17, 2012, 04:15:35 AM
Hola hola, aca mi duda:
Todos sabemos que el draw_set_color(c_white) dibuja la imagen normal y el c_black dibuja la misma imagen pero en negro.
Hay alguna forma de hacerlo al reves? osea que con c_white se dibuje la imagen pero en blanco respetando solo el alpha y no el color, y con c_black se dibuje normal?? Habr? alguna forma usando los blend_modes??

Gracias
        Ciberman
Título: Re: Aclarar una imagen
Publicado por: NOKAUBURE en Enero 17, 2012, 04:31:16 PM
Pues no, pero hay scripts para dar "textura" a los sprites. Simplemente creas un quadro blanco con opacidad del 50% de sprite, y luego a la imagen para aclarar aplicas el siguiente script:

merge_sprite
[gml]//argument0=sprite
//argument1=subimage
//argument2=sprite form
//argument3=subimage of form
//argument4=append to a existing sprite
fspr=-1
if argument1=all
{
if sprite_exists(fspr) {sprite_delete(fspr)}
for (i=0;i<=sprite_get_number(argument0)-1;i+=1)
{
erase=surface_create(sprite_get_width(argument2),sprite_get_height(argument2))
surface_set_target(erase)
draw_clear_alpha(c_white,0)
draw_rectangle(0,0,sprite_get_width(argument2),sprite_get_height(argument2),0)
draw_set_blend_mode(bm_subtract)
draw_sprite(argument2,argument3,sprite_get_xoffset(argument2),sprite_get_yoffset(argument2))
draw_set_blend_mode(bm_normal)
surface_reset_target()
spr=surface_create(sprite_get_width(argument0),sprite_get_height(argument0))
surface_set_target(spr)
draw_clear_alpha(c_white,0.01)
draw_sprite(argument0,i,sprite_get_xoffset(argument0),sprite_get_yoffset(argument0))
draw_set_blend_mode(bm_subtract)
draw_rectangle(sprite_get_width(argument2),0,sprite_get_width(argument0),sprite_get_height(argument0),0)
draw_rectangle(0,sprite_get_height(argument2),sprite_get_width(argument2),sprite_get_height(argument0),0)
draw_surface(erase,0,0)
draw_set_blend_mode(bm_normal)
surface_reset_target()
if !sprite_exists(fspr) {fspr=sprite_create_from_surface(spr,0,0,sprite_get_width(argument0),sprite_get_height(argument0),0,0,0,0)}
else {temp=sprite_create_from_surface(spr,0,0,sprite_get_width(argument0),sprite_get_height(argument0),0,0,0,0) sprite_merge(fspr,temp)}
}
return fspr
}
else
{
erase=surface_create(sprite_get_width(argument2),sprite_get_height(argument2))
surface_set_target(erase)
draw_clear_alpha(c_white,0)
draw_rectangle(0,0,sprite_get_width(argument2),sprite_get_height(argument2),0)
draw_set_blend_mode(bm_subtract)
draw_sprite(argument2,argument3,sprite_get_xoffset(argument2),sprite_get_yoffset(argument2))
draw_set_blend_mode(bm_normal)
surface_reset_target()
spr=surface_create(sprite_get_width(argument0),sprite_get_height(argument0))
surface_set_target(spr)
draw_clear_alpha(c_white,0)
draw_sprite(argument0,argument1,sprite_get_xoffset(argument0),sprite_get_yoffset(argument0))
draw_set_blend_mode(bm_subtract)
draw_surface(erase,0,0)
draw_set_blend_mode(bm_normal)
surface_reset_target()
return sprite_create_from_surface(spr,0,0,sprite_get_width(argument0),sprite_get_height(argument0),0,0,0,0)
}[/gml]

Uso: merge_sprite(spritequadroblanco,0,sprite_index,image_index)
con esto, tu sprite se aclararia. Si no funciona, cambia el 0 por all.
Título: Re: Aclarar una imagen
Publicado por: Ciberman en Enero 17, 2012, 08:34:26 PM
mh.. muy buen script aunque lo veo medio dificil de implementar en lo que tengo hecho...
Título: Re: Aclarar una imagen
Publicado por: brunoxzx en Enero 20, 2012, 10:31:11 AM
Hasta donde tengo entendido es imposible hacer una imagen completamente blanca usando blend modes...

Aunque por all? en la yoyo alguna vez vi que se pod?a hacer usando la neblina del 3d.
[gml]d3d_set_fog(1, c_white, 0, 0);
//Tu sprite
d3d_set_fog(0, 0, 0, 0);[/gml]

Espero que te sirva.