• 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!

Legacy GM when room start start sprite at specific image.

TheouAegis

Member
Create or Room Start event of a control object in the room:
selection=0;

Key Right Pressed event:
selection++;
if selection == 3 selection=0;

Key Left Pressed event:
selection--;
if selection == -1 selection=2;
 

TheouAegis

Member
it's not going to do anything because that's essentially the skeleton code. You still need to tell it to draw the correct sprites.
 
R

Red Phantom

Guest
hey yall,
wanted to start this battle bar at a specific sprite when the room starts and can be changed by pressing the arrow keys, anyone have any examples?
Assuming it is a single sprite with different images:
Starting the bar at a specific sprite
Create or Room Start event of the object:
image_index = 0 {assuming you have index 0 as your desired initial image}
image_speed = 0
Changing the bar by pressing left and right
Step event of the object:
if keyboard_check_pressed(vk_right) and image_index != 2 then image_index += 1 //moves yellow selection right
if keyboard_check_pressed(vk_left) and image_index != 0 then image_index -= 1 //moves yellow selection left

Create a single sprite, with your bar images as the 3 images of the sprite (in order, so that they line up as image_index 0, image_index 1 and image_index 2 for the code).

Let me know if this helps.​
 
E

EZTALES

Guest
Assuming it is a single sprite with different images:
Starting the bar at a specific sprite
Create or Room Start event of the object:
image_index = 0 {assuming you have index 0 as your desired initial image}
image_speed = 0
Changing the bar by pressing left and right
Step event of the object:
if keyboard_check_pressed(vk_right) and image_index != 2 then image_index += 1 //moves yellow selection right
if keyboard_check_pressed(vk_left) and image_index != 0 then image_index -= 1 //moves yellow selection left

Create a single sprite, with your bar images as the 3 images of the sprite (in order, so that they line up as image_index 0, image_index 1 and image_index 2 for the code).

Let me know if this helps.​
SOLVED! thanks bud! wow, i cant believe i didn't think of that on my own, but one question for you, for future reference, would it be possible to make those specific sprites open different objects?, for example, what if i wanted the spells sprite to open the spells window? just a quick one. thanks though!
 
Check for the image_index number on a keypress:
Code:
if (keyboard_check_released(vk_space) {
 switch (image_index) {
  case 0:
    // Open spells
  break;
  case 1:
    // Open something else
  break;
  case 2:
    // Etc
  break;
 }
}
 
Top