Give value from C# to c2runtime

0 favourites
  • 4 posts
  • Hello, I decided to develop a new game with C2, when I run into a problem that I couldn't solve by myself. I decided to make a pseudo-3D balance game on Windows Phone 8, where you have to avoid obstacles by tilting your phone left or right. Cause I found out that there is a problem with C2 getting readings from the phone acceleometer, I implemented the same thing in C#. This solution works well and shows the correct reading in the Textblock I made on the canvas, but I would like to take this variable and begin to assign it to a global variable called phoneBeta and set the character angle according to the tilt of the phone.What I basically would like to do is double y->phoneBeta, where y is a c# variable in MainPage.xaml.cs and phoneBeta is javascript global variable in c2runtime. Cause I dont't really know how to change c2runtime file in Visual Studio so that this would work, I would like to ask if someone could give me a solution to this problem.

    Here is the .capx with tha basic concept:

    http://www.upload.ee/files/3886922/test.capx.html

    Here is the Visual Studio .zip: http://www.upload.ee/files/3886322/New_project.zip.html

  • bumping

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I have been able to inject the variable into c2runtime, but I still can't set the value of the c2runtime global variable to the variable I am sending from C# code. I can call it with alert, but it is not set to global variable. I have modificated c2runtime, by changing "Set phoneBeta->99" to "Set phoneBeta->change",which is the new varaible I have created.

    I have added these lines to c2runtime to call the value out, it is located in the beginning of the c2runtime

    window["wp_muuda"] = function (value) {

        change = value;

       // alert(change);

    }

    and set the value of the global variable to "change", it is located in the end of c2runtime:

    cr.system_object.prototype.acts.SetVar,

                        null,

                        1421252773806425,

                        false

                        ,[                     [                          11,                          "phoneBeta"                     ]

    ,                    [                          7,                          [                             ��1,                             ��change//made change                          ]

                        ]

                        ]

    The injection method is called out in MainPage.xaml.cs.

    I would really appreciate, if someone would crack this issue for me.

    New visual studio file using the windowsphone plugin:

    http://www.upload.ee/files/3893236/Project.zip.html

    New project:http://www.upload.ee/files/3893240/test.capx.html

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)