Give value from C# to c2runtime

Get help using Construct 2

Post » Thu Feb 13, 2014 7:26 pm

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.htmltrollface2014-02-14 07:42:18
B
14
S
5
G
4
Posts: 107
Reputation: 4,788

Post » Fri Feb 14, 2014 6:17 am

bumping
B
14
S
5
G
4
Posts: 107
Reputation: 4,788

Post » Fri Feb 14, 2014 8:58 am

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

Post » Mon Feb 17, 2014 6:43 pm

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
B
14
S
5
G
4
Posts: 107
Reputation: 4,788


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest