Ralf
Member
Greetings,
I'm discovering (and enjoying !) Gamemaker, and started to watch several hours of tutos before starting my own.
I'm already facing a problem : I'd like to personalize a selected character with a menu, but I don't know how to "give" him informations.
What I have done so far :
"player_number" is a variable created for the menu, to give it the gamepad (and so the player) number.
It "works", as the menu is effectively "linked" to the right player instance : if I use the gamepad 2, I move into menu 2.
Now the tricky part : after used this menu, I need to pass the new information to the right instance !
In this menu, I can select a "class" for the character (knight, wizard...).
Of course, this code doesn't work :
because the "menu[menu_committed]" information (knight, wizard...) will be send to all player object instances, and that's not what I want. The first player could chose knight, the player 2 the wizard...
Is it possible ton send back an info to the "parent" instance (the one which created this one...) ?
Am I completely wrong about the logic of what I want ? Should I use instance IDs ?
After that, all is ready in my code : each player object instance will change its sprites according to the right keyword of my menus (knight...), but I need to give that information to the player object instances !
Thank you for your time.
I'm discovering (and enjoying !) Gamemaker, and started to watch several hours of tutos before starting my own.
I'm already facing a problem : I'd like to personalize a selected character with a menu, but I don't know how to "give" him informations.
What I have done so far :
- detected plugged gamepads
- created an instance of a "player object" for each plugged gamepad
- In "player object", I have a step event : if I press a button, an instance of a "menu object" is created. So, each "player object" instance creates its own "menu object" instance.
- I can pass informations from player instance to the menu it's created, with :
GML:
var inst = instance_create_layer(x - (128 / 2), y + 250, "layer_players", obj_menu);
with (inst) {
player_number = other.pad_num;
}
It "works", as the menu is effectively "linked" to the right player instance : if I use the gamepad 2, I move into menu 2.
Now the tricky part : after used this menu, I need to pass the new information to the right instance !
In this menu, I can select a "class" for the character (knight, wizard...).
Of course, this code doesn't work :
GML:
if (gamepad_button_check_pressed(player_number, gp_face1)) {
obj_player.character = menu[menu_committed];
}
Is it possible ton send back an info to the "parent" instance (the one which created this one...) ?
Am I completely wrong about the logic of what I want ? Should I use instance IDs ?
After that, all is ready in my code : each player object instance will change its sprites according to the right keyword of my menus (knight...), but I need to give that information to the player object instances !
Thank you for your time.