1

I have been trying to put together a prototype for airconsole, based on construct2 but I am having trouble in paradise. Using the "pong" game exemple, I started with this kind of thing to store every device ID : http://developers.airconsole.com/images/examples/construct2/example_event_sheet.png The problem I am having is that I receive, whenever the game is ready, all the controller joining under the same ID... the ID of the first controller. Even if the simulator only has 2 connected devices. I am really having a hard time figuring this out. I decided then to try to make my own custom airconsole.onConnect(). But I am failing to make it work properly to stock my controller IDs for some ready.. :(

    airconsole.onConnect = function() {
    var deviceID = airconsole.getDeviceId();
    console.log(deviceID);
    airconsole.message(AirConsole.SCREEN, {
            "message": '{"c2dictionary":true,"data":{"controller_ID":' + deviceID + '}}'
    });
};

Mostly because I dont know how to receive the message back :D. Does anyone has any clue as to what could happen here. Couldnt find anything...

Thanks a lot !

Maelienne
  • 11
  • 1
  • Which construct2 AirConsole plugin do you have installed? onConnect is only called for other devices which connect but not for the own one. You have to use the Game ready event http://developers.airconsole.com/#!/guides/construct2 – Zeus Oct 31 '16 at 15:25

1 Answers1

0

First, you will need to broadcast the game being ready in Construct 2. You will then listen for incoming controller messages:

enter image description here

Every message coming from the controllers carry the device id, so you don't need any of your complexe function to retrieve this id

You need a very basic controller javascript code:

enter image description here

These very simple steps are decribed in the official AirConsole Construct 2 plugin guide: AirConsole Construct 2 plugin

Per exemple, if you wanted to store the device ids of 4 controllers, that's simple Construct 2 coding then. Declare some variables to hold the ids, and set them :)

enter image description here

Psychokiller1888
  • 620
  • 2
  • 10
  • 25