Call C2 Function as callback for external js.

Get help using Construct 2

Post » Mon Dec 16, 2013 11:18 am

My client requested me to add his advertising into game. Call to Browser.ExternalJS needs to have this form:
request(fnPause, fnResume)

Wchich means I need to pass js functions there that will stop or resume gameplay. How do i do that?

Preferably WITHOUT writing plugin. If plugin needs to be written im willing to pay for it.PKrawczynski2013-12-16 11:19:20
B
22
S
7
Posts: 94
Reputation: 1,783

Post » Mon Dec 16, 2013 11:35 am

Is there a way to get access to timescale with ExternalJS I dont care how dangerous it could be. Need to have way to change it on those callbacks.
B
22
S
7
Posts: 94
Reputation: 1,783

Post » Mon Dec 16, 2013 11:56 am

Is there a reason it should be externally?
Why not use what you have at your disposal inside Construct2?
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Dec 16, 2013 12:16 pm

[QUOTE=LittleStain] Is there a reason it should be externally?
Why not use what you have at your disposal inside Construct2?[/QUOTE]

Because I need to call external js to show ads and their js needs to control if game should be paused or not. Thats how it needed to be done - Ive managed.

I just had to hack my code inside of prototype.logic function with simple boolean that optionally skips whole logic loop. Added 2 window functions - stopGame and resumeGame they are basically available everywhere as "cr_..." function is called in index.html.

Only disadvantage is that i will have to edit my c2runtime everytime I make adjustment for client but it only takes 1 minute so I can live with that.
B
22
S
7
Posts: 94
Reputation: 1,783

Post » Mon Dec 16, 2013 1:07 pm

You should just write a plugin. It really shouldn't be that hard if you already know javascript.
Scirra Founder
B
402
S
238
G
89
Posts: 24,628
Reputation: 196,023

Post » Mon Dec 16, 2013 5:36 pm

[QUOTE=Ashley] You should just write a plugin. It really shouldn't be that hard if you already know javascript.[/QUOTE]

I dont know JS. I do have coding experience but I pretty much hate JS.
No idea also how this sort of plugin would work. How would it allow external js to control game timescale.

Either way hacky workaround is good enough as it does job it should.
B
22
S
7
Posts: 94
Reputation: 1,783


Return to How do I....?

Who is online

Users browsing this forum: adelwich, kizlengames, WesleyDeveloper9 and 9 guests