How do I multiple inputs

Get help using Construct 2

Post » Mon Mar 23, 2015 11:27 pm

Hello.

I'm working on a multilayer game. were one player can use a keyboard and the others can us Xbox controllers. the order won't matter.

I"m able to tell the difference in input just fine. My problem is assigning a control device to a player and over multiple layouts.

what I want is you start at the player start up screen/layout. here each player would press "A" on there controller to say that it's in use. (meaning you could use controllers 1,2 and 4, but not 3)

then as they went to the next layouts(depending on the level they select) each player would be given control of a random NPC that is on the stage. this would repeat though all the layouts.

How I had it set up in my test layout when I first started was making a global variable that I would set to the number of players I wanted. it would then create an object called "player" once for how big the variable was. and increment a variable inside that instance to tell it what controller it had.

Then in the main loop were input would be collected I had a "for loop" that would go though each Player instance. And looking at it's variable would collect input from that device, and apply it to the NPC by means of an ID the NPC has. (each player object holds this id so it knows what NPC this player controls)

This worked well... when the project was one sheet. however now I'm not sure how to carry the player input data over from the start screen. is there a way to spawn my "player" objects in my start screen. then have them stay throughout the game? or should I store the data in global variables? and if I store them in global variables how would I reference that in a forloop for each player?

Thanks much
B
10
S
4
Posts: 52
Reputation: 856

Post » Tue Mar 24, 2015 12:23 pm

Add an unique invisible sprite for each player in your start screen and make these global objects.
Store your settings for the player in the sprites variables, and use the sprite for each player to reference them in your game.

The global object will not get destroyed and will keep the information.


ie

Player1sprite.controller = 1
Player1sprite.name = player 1

Player2sprite.controller = 2
Player2sprite.name = player 2

etc
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,552

Post » Tue Mar 24, 2015 4:21 pm

awesome. thanks man!
B
10
S
4
Posts: 52
Reputation: 856


Return to How do I....?

Who is online

Users browsing this forum: Lancifer, Mayfly and 5 guests

cron