Sprite: spr_button
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent:
Children:
Mask:
No Physics Object
Create Event:
execute code: image_speed=0; letter = "A";//set letter
Step Event:
execute code: if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x,mouse_y,id)//if clicked { global.message+=letter;//add letter to string } if position_meeting(mouse_x,mouse_y,id) { image_index=1; } else { image_index=0; }
Draw Event:
execute code: draw_self(); draw_set_font(fnt_button); draw_set_halign(fa_center); draw_text(x+16, y+4, letter);//draw letter over button
obj obj_enter
create event:
//creating all the buttons //top row var alphabet = "QWERTYUIOP"; for(var i = 0; i<10; i++){ var bt = instance_create(64+i*32+(8*i), 64, obj_button); bt.letter = string_char_at(alphabet, i+1); } //middle row var alphabet = "ASDFGHJKL"; for(var i = 0; i<9; i++){ var bt = instance_create(72+i*32+(8*i), 104, obj_button); bt.letter = string_char_at(alphabet, i+1); } //BOTTOM row var alphabet = "ZXCVBNM"; for(var i = 0; i<7; i++){ var bt = instance_create(88+i*32+(8*i), 144, obj_button); bt.letter = string_char_at(alphabet, i+1); } global.message="";
step event:
if mouse_check_button_pressed(mb_left) && position_meeting(mouse_x,mouse_y,id)//if clicked
{
show_message(global.message);//show typed string
game_restart();
}
draw event: draw_set_halign(fa_left);
draw_text(50,300,"Word "+global.message);//show typed text so far
draw_self();
No comments:
Post a Comment