• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

avatar frame

H

hadi

Guest
Hi there.
anyone know any way to make a avatar frame for example draw rounded sprite or draw circle sprite without editing sprite in sprite editor


please help :(
thanks
 
Last edited by a moderator:

sp202

Member
Surfaces and blend modes, have a quick read of them first. This should do the trick:
Code:
surface_set_target(tempSurface)
draw_clear_alpha(c_white,0);
draw_set_blend_mode_ext(bm_one, bm_one);
//draw frame
surface_reset_target();
draw_set_blend_mode(bm_normal);

surface_set_target(surface);
//draw sprite
draw_set_blend_mode_ext(bm_zero, bm_src_color);
draw_surface(tempSurface,0,0);
surface_reset_target();
draw_set_blend_mode(bm_normal);

//draw the surface called "surface"
Remember to create the surfaces and to put the above code in the draw event.
 
H

hadi

Guest
Surfaces and blend modes, have a quick read of them first. This should do the trick:
Code:
surface_set_target(tempSurface)
draw_clear_alpha(c_white,0);
draw_set_blend_mode_ext(bm_one, bm_one);
//draw frame
surface_reset_target();
draw_set_blend_mode(bm_normal);

surface_set_target(surface);
//draw sprite
draw_set_blend_mode_ext(bm_zero, bm_src_color);
draw_surface(tempSurface,0,0);
surface_reset_target();
draw_set_blend_mode(bm_normal);

//draw the surface called "surface"
Remember to create the surfaces and to put the above code in the draw event.
thanks for answer but according to photo sprite edges must be not shown while draw_set_blend only can change the color and alpha
 
F

fxokz

Guest
Hi there.
anyone know any way to make a avatar frame for example draw rounded sprite or draw circle sprite without editing sprite in sprite editor


please help :(
thanks
I learned how to do this a few days ago actually.. its quite simple..
What you want to do is:
1. Create a surface
2. Draw your sprite
3. Draw frame
4 use a sprite mask and bm subtract to remove the unwanted edges..

ill post the topic that saved me shortly.
EDIT: okay so for some reason i cant link it on my phone.. the thread is called "is this possible?" Started by me.
 
Last edited:
H

hadi

Guest
Give that piece of code a try, it does exactly what you want.
Code:
if!(surface_exists(tempSurface)){tempSurface=surface_create(room_width,room_height)}
if!(surface_exists(surface)){surface=surface_create(room_width,room_height)}

surface_set_target(tempSurface)
draw_clear_alpha(c_white,0);
draw_set_blend_mode_ext(bm_one, bm_one);
//draw frame
draw_sprite(spr_frame,0,100,100)
surface_reset_target();
draw_set_blend_mode(bm_normal);

surface_set_target(surface);
draw_sprite(spr_sprite,0,100,100)
draw_set_blend_mode_ext(bm_zero, bm_src_color);
draw_surface(tempSurface,0,0);
surface_reset_target();
draw_set_blend_mode(bm_normal);

//draw the surface called "surface"
draw_surface(tempSurface,0,0);
 

sp202

Member
Ah, the issue was you were drawing the wrong surface in the end. You drew the tempSurface, I did specify the other one.
 
H

hadi

Guest
Ah, the issue was you were drawing the wrong surface in the end. You drew the tempSurface, I did specify the other one.
i tried both before , but my mistake was that using a empty rounded rectangle instead of black
thanks a lot ,you guys helped me to learn this :)
 
Top