I am currently in the process of exploring the possibilities of Construct 2 for us. Figuring out if we can do with it what we need but i have hit a problem.
This is mainly because we want to create a game that more or less has an infinite amount of levels. So instead of letting construct 2 create levels we have decided to do this with PHP (?level=2 etc.) What i need now is a way to adjust the values of the global variables with information retrieved from the database.
But i cannot seem to be able to figure out how to change the values of the global variables within the index.php page without using ajax/xml/json request within construct 2.
Hopefully somebody is able to assist me with my issue. Or provide me with information if there are better/easier ways to achieve this.
PS: Sorry for any english writing mistakes.
Sry for my bad English.
So the logic is:
1. Ajax Request on a Php file with some Parameters
2. Php file makes the database request and some magic stuff with the data
3. Ajax on complete, save the result in your global variables.
The other Problem is that Php is a server side language, it just makes something if you say "Hei Php go" and than it will execute your code one time, not more.
No other tool like Gamesalad, Gamemaker and so on can work with Php files without Ajax, Json and so on. Not even native code!
Develop games in your browser. Powerful, performant & highly capable.
Yes i fully understand that but my question is more:
$a = 'hello';
var a = <?php echo json_encode($a); ?>;
But then apply that for the global variables in construct 2. So i could change the information in the variables based on the level dynamically. Simply by encoding the raw string data retrieved from the database.
But i would like to prevent editing the runtime.js and rather be able to do this on the index.html(.php) page.
This is possible but no good idea because variables can be changed anytime you change your construct code.
But if you think you will never update your game, you could do this with JQuery or PhpQuery.
if you have a real example I could tell you how to do it easily.
Thank you for replying, i have found a way to get variables into the game now through a different route. The callJS plugin did it.