cjbruce's Forum Posts

  • cjbruce You surely are doing something wrong , does the Pong example work for you ? I recommend that you go from there and examine the event sheet, remember that you need to allow the devices to connect first so that OnDeviceJoin and OnDeviceLeft can work.

    X3M

    The pong example works fine, but it does not include an example of sending a message to the controllers other than a handshake.

    I'm porting an existing project that has been working for months now, and trying to remake the controllers in C2, instead of by hand.

  • cjbruce Yep that's the issue, there should be only one handshake per controller, I'll update later.

    Edit: That is weird because it is working fine with the pong demo. Have you tried testing on an Android device?

    Edit: Add this line :

    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>[/code:3n1l9htq] To the <head> of controller.html and tell me if it fixes the problem.
    

    X3M,

    No luck with the scaling problem. I wonder if it is a javascript issue. My existing code:

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui" />[/code:3n1l9htq]
    
    The not receiving messages from the screen.html is driving me crazy.  I've spent several hours adding alerts in different spots in c2runtimectrl.js and/or in the event sheet.  All of the alerts I place directly into the code fire properly, but whenever I try to trigger an alert based on an AirConsole condition (OnDeviceJoin, OnMessage, etc.), I get nothing.  I've even tried to fiddle with the ExecJS() expression in Construct 2 to get the status of the message directly, but no luck so far.  Maybe I can create a variable at the beginning of the controller.html called "airconsoleMessageFromTheScreen", and set its value directly?
    
    Also, I still can't get the OnDeviceJoin and OnDeviceLeft conditions to work.
    
    I'm getting really flumoxed, and running out of ideas...
  • Findings after more testing:

    1. When using a controller created in C2 with the two plugins, OnDeviceJoin is not called in screen.html.

    2. The screen doesn't seem to be resizing correctly on my phone (iPhone 7 plus) or iPad. The screen is resizing correctly in the simulator (Nexus 5).

  • X3M and Psychokiller1888,

    I was poking through the code, and realized that the following lines are duplicated for buttons in the AirConsoleController. If I'm not wrong, this means that "sendHandshake()" will get called twice, and it is redeclaring the sendHandshake function:

    var sendHandshake = function () {
    				_this.airconsole.message(AirConsole.SCREEN, {
    					handshake: true
    				});
    			};
    			_this.airconsole.onReady = function () {
    				sendHandshake();
    			};
    			_this.airconsole.onMessage = function (device_id, data) {
    				if (data.handshake) {
    					sendHandshake();
    				}
    			};[/code:21donbb9]
    
    I don't know if the above really affects anything.
    
    Also, I placed an alert in c2runtimectrl.js to verify that messages are getting received by the controller and handled in this.air_console.onMessage (created by the AirConsole plugin, not the AirConsoleController plugin).  My alert fires when I place it directly into the code, but a similar alert for the onMessage trigger placed in a Construct 2 event sheet does not fire.
  • X3M,

    Also, the console is seeing a lot of handshake errors in the simulator:

    Message to 0: {\"handshake\":true}

  • cjbruce Have you tried creating an Airconsole object in your controller and getting the nickname inside an OnDeviceJoin condition?

    I think that the nickname that you will get is yours, If I'm not wrong. It is worth a try.

    X3M,

    No luck. The OnDeviceJoin condition doesn't fire on the controller side. Just for kicks, I tried an alert with OnDeviceJoin on start of layout, and the alert showed "null" for the airconsole.nicknamejoin because it had not been set yet.

  • X3M and Psychokiller1888,

    I've played around a bit with the plugin, but have not been able to send messages from the screen back to the controller. A few questions:

    1. I assume that the sendhandshake() message is being sent from the screen to the controller, then back from the controller to the screen, all handled behind the scenes by the AirConsoleController plugin on the controller side and the AirConsole plugin on the screen side. Is this correct?

    2. Since the airconsoleController plugin doesn't have any event triggers or expressions to receive messages, I am using the AirConsole plugin on the controller side to try to receive messages. I have tried the following, neither of which seem to work:

    I need to be able to send the following types of information from the screen to the controller:

    airconsole.nickname

    the current screen to display (loading game, too many players, character selection screen, in-game screen, game over screen)

    Is this something that needs to be handled in the controller plugin or the screen plugin?

    Thanks for your help on this!

  • X3M,

    In order to force a landscape orientation, I added {"orientation":"landscape"} to the c2runtimectrl.js:

    So, instead of:

    			_this.airconsole = new AirConsole();[/code:3p6imdde]
    
    I used the following:
    
    [code:3p6imdde]
    			_this.airconsole = new AirConsole({"orientation": "landscape"});[/code:3p6imdde]
    
    Could this capability be added directly to the plugin?
  • Anonnymitet Just adding some stuff

    cjbruce I'm testing all the possibilities

    X3M,

    Thank you!

    I haven't (yet) figured out how to modify the code in c2runtimectrl.js to lock orientation in landscape. I'll keep poking around and (hopefully) post a solution here once I figure it out.

  • > cjbruce

    > 1- I'm figuring this out ... Have you tried triggering a message inside your condition ? Like on mouse click on sprite -> send message "up". ?

    > 2- Yes

    > 3- Fake it by rotating your controls 90 degrees and align them vertically so the the play is forced to hold the smart-phone horizontally.

    >

    X3M - You rock!

    1. Working on it now. I'm building a simple screen.html to test.

    2. Sounds good. Sometimes HTML elements get a little wonky on screen rotations for mobile devices, but hopefully this isn't an issue if I don't make the actual buttons themselves visible.

    3. Will do. When I am normally writing a controller.html file, I set AirConsole.ORIENTATION_LANDSCAPE in javascript. I don't have everything running yet, but I just wanted to make sure the controls rotate when I move the phone around.

    Orientation is a little weird in portrait. The AirConsole logo is sideways, and on the side of the screen. I'm working on manually modifying c2runtimectrl.js to lock the orientation in landscape. Is it possible to modify the plugin to set an orientation?

  • cjbruce

    1- I'm figuring this out ... Have you tried triggering a message inside your condition ? Like on mouse click on sprite -> send message "up". ?

    2- Yes

    3- Fake it by rotating your controls 90 degrees and align them vertically so the the play is forced to hold the smart-phone horizontally.

    X3M - You rock!

    1. Working on it now. I'm building a simple screen.html to test.

    2. Sounds good. Sometimes HTML elements get a little wonky on screen rotations for mobile devices, but hopefully this isn't an issue if I don't make the actual buttons themselves visible.

    3. Will do. When I am normally writing a controller.html file, I set AirConsole.ORIENTATION_LANDSCAPE in javascript. I don't have everything running yet, but I just wanted to make sure the controls rotate when I move the phone around.

  • X3M,

    Thank you for making this! This opens up a whole number of possibilities for gameplay. I am playing with the demo .capx now, and have a few questions:

    1. Is there a way to change the images on buttons? Or should we just not include the image files (leaving the button invisible, but still active), and instead put sprites onscreen underneath the buttons?

    2. Are the controls themselves HTML elements?

    3. Is it possible to lock orientation to landscape?

  • cjbruce It gives you the device id through "AirConsole.deviceIdJoin as this was a join action

    Here's what I tried, unsuccessfully:

    1. Set AirConsole->max players to 8

    2. In the simulator, "Add a New Controller" to create a total of 9 players.

    3. The first 8 players triggered an "On Device Join".

    4. The 9th player did not trigger an "On Device Join".

    What I have not tried:

    Instead of looking for an "On Device Join" for the 9th player, instead I should be using the "On Too Many Players" trigger, then inside its action use the "AirConsole.DeviceIDJoin" expression to get the deviceID of the 9th player?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You have a ''on too many players'' trigger for that...

    I was struggling with this one. Does "on too many players" give you the deviceid of the device which is trying to join? Maybe using AirConsole.deviceID?

  • QuaziGNRLnose

    Is there a simple demo on how to get a 3D character model (w/ walking animations) to work in a 2D environment?

    I couldn't find anything like this in the tutorials.

    So in a 2D environment the camera angle on the 3D character model would be locked to a diagonal view, the actual Player object will be a 2D invisible sprite that moves, and the 3D model will just position itself on top of this invisible sprite at all times - so 3D character model would be for appearance only.

    Badmiracle,

    Since you are just using the 3D model for appearance only, could you pre-render your 3D animations, then import them into a 2D sprite strip in Construct 2? There are a number of good tutorials on this, and you will save a lot of CPU time (at the expense of download time and memory).