【GameMaker】 change sprite color using color pallete

Information about object: obj_pallete
Sprite: spr_palette
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code:

ini_open("colours.ini");//open file
global.save = ini_read_real("colours","colour",0)
ini_close();//close ini
if(global.save  == 0){
my_colour=c_black;
}else{
my_colour = global.save;
}

Mouse Event for Left Released:
execute code:

if position_meeting(x,y,id)
{
my_colour=draw_getpixel(mouse_x,mouse_y);
global.save = my_colour
ini_open("colours.ini");//open ini
ini_write_real("colours","colour",my_colour);//write a value
ini_close();//close value

}
Draw Event:
execute code:

draw_self();
draw_set_colour(my_colour);
draw_circle(x,y,40,false);



Information about object: obj_red
Sprite: spr_red
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Step Event:
execute code:

if (keyboard_check(ord('A')))  {x-=5;} //make inst move
if (keyboard_check(ord('D')))  {x+=5;} 
if (keyboard_check(ord('W')))  {y-=5;} 
if (keyboard_check(ord('S')))  {y+=5;}
Draw Event:
execute code:


draw_self();
draw_set_colour(global.save);
draw_sprite_ext(sprite_index, sprite_index, x, y, 1, 1, 0, global.save, 1);

No comments:

Renowned Water Expert Reynold Aquino Offers Exclusive Water Softener Discounts

Los Angeles, California - November 21, 2024 - World-renowned water expert Reynold Aquino is excited to announce exclusive discounts on prem...

Contact Form

Name

Email *

Message *