[Plugin] AirConsole - local multiplayer for your game

Post your completed addons to share with the community

Post » Wed Feb 15, 2017 5:16 am

@Psychokiller1888

I'm trying to change the button image background. I was trying with this code but is not working.

Is this the right way to do it?


https://drive.google.com/file/d/0B2tJAThC4ueZeEl0aEY5OUQyT1E/view?usp=sharing
B
11
S
2
G
1
Posts: 45
Reputation: 1,238

Post » Wed Feb 15, 2017 8:33 am

Not at all, what is that if condition?? The jquery to change the css looks good though. Use console.log() to output Infos to your browser. Then a very simple and quick Javascript beginner guide will help you in no time. I'm not on computer, won't type the function on my phone.

BTW you deleted the handshake in onmessage, that won't work until plugin v. 2
Last edited by Psychokiller1888 on Wed Feb 15, 2017 10:16 am, edited 1 time in total.
B
24
S
8
G
3
Posts: 156
Reputation: 3,624

Post » Wed Feb 15, 2017 3:38 pm

@Psychokiller1888

Where can I find the very simple and quick Javascript beginner guide?
Do I have to put the "if" condition inside the handshake.data?
How do I get the values from the browser?

Sorry I'm in a rush, just a few days left for submitting the game.

Thank You!
B
11
S
2
G
1
Posts: 45
Reputation: 1,238

Post » Thu Feb 16, 2017 9:40 pm

@arod17pr
As for the handshake and passing data this is a quick example of it would work. Keep in mind if you are referencing the Device_ID since it's coming from the screen the value would be 0 for Device_ID

air_console.onMessage = function(device_id, data) {
if (data.handshake) {
sendHandshake();
}

// The data red would be coming from the screen and changes Player 1 background to red
if (data == "red")
{
document.getElementById("changeBody").style.backgroundColor = "#B73338";


}

};

As for basic Javascript tutorials you can check W3Schools :)
Image
B
40
S
19
G
4
Posts: 85
Reputation: 5,877

Post » Fri Feb 17, 2017 12:26 am

@ishmaelmoreno

It works! Thanks!

But I'm trying to add a different background color for each controller and for that it does not work.

Is there a way to get the device_id?

How can I do that?
B
11
S
2
G
1
Posts: 45
Reputation: 1,238

Post » Fri Feb 17, 2017 3:17 am

@arod17pr never tried getting the deviceid from the controller itself but the simpliest thing you can do is from construct 2 say if deviceid1 joins you can set the action to send data > " red " and in the controller itself is the if data == "red" change background colour just like code shown earlier and same would apply to a deviceid2 instead you would put "blue". Hope this helps you :)

Also for the background colour to change you would need to reference the body or the div if it's in a container.
Image
B
40
S
19
G
4
Posts: 85
Reputation: 5,877

Post » Fri Feb 17, 2017 5:13 am

@ishmaelmoreno

Thank you! It works perfectly.

Now, i'm wondering how could I get the Device Nickname?

Thanks!
B
11
S
2
G
1
Posts: 45
Reputation: 1,238

Post » Fri Feb 17, 2017 5:34 am

@arod17pr no problem ! i'm always glad to assist a fellow developer :) also what are you thinking about doing? retrieving the nickname and displaying it on the controller itself?
Last edited by ishmaelmoreno on Fri Feb 17, 2017 5:51 am, edited 2 times in total.
Image
B
40
S
19
G
4
Posts: 85
Reputation: 5,877

Post » Fri Feb 17, 2017 5:37 am

https://developers.airconsole.com/#!/api

AirConsole.getNickname() is enough for you to get the nickname of a controller :)

As getDeviceId() does return a device's id
Last edited by Psychokiller1888 on Fri Feb 17, 2017 5:41 am, edited 1 time in total.
B
24
S
8
G
3
Posts: 156
Reputation: 3,624

Post » Fri Feb 17, 2017 5:37 am

Yes! Exactly that!
B
11
S
2
G
1
Posts: 45
Reputation: 1,238

PreviousNext

Return to Completed Addons

Who is online

Users browsing this forum: AugustoMarcelo and 1 guest