hello. i created an event that starts a game when user clicks an image
i want to add a javascript function before that events (or, as the first command of the event) that makes an ajax request to the server about opening a new game, then waits for the server to reply the game_id, and then continue with the rest of the event.
i come from the world of javascript and i have pretty good knowlagde of how things are done. (i just havn't found the feature in the construct2 editor...)
and i want to do it without the need to start reading and understanding the entire generated construca code.
little example of what i mean
// pseado-code of how it is now
"function (){
game_id = null
number_of_balls = 4
gender = 'male'
etc...
startShootingBalls()
}"
// as i want it to be
"function (){
$.post('/new_game',function(response) {
game_id = response.game_id
number_of_balls = 4
gender = 'male'
etc ...
startShootingBalls()
}
}"
is there an easy way to do it?
thanks