r103 breaks my plugin tutorial demo (ctx is null)

For developers using the Construct 2 Javascript SDK

Post » Sat Sep 29, 2012 5:52 am

I created my (prize-winning ) plugin tutorial using stable release r95. Running it with WebGL switched on (the default) under the latest stable release (r103.2) now produces a JavaScript error ("Type error: ctx is null"). Here's how it happens:

In order to keep things as simple as possible, I simply had a call to instanceProto.drawGL() fall through to instanceProto.draw(), passing this.runtime.overlay_ctx as the context (I'd pinched this code from shinkan's Square plugin):
[CODE]instanceProto.drawGL = function (glw) {
this.draw(this.runtime.overlay_ctx);
};[/CODE]
However, since r103.2 (or possibly before - I didn't test it with the intervening beta releases), runtime.overlay_ctx returns null.

In any case, when I think about it, overlay_ctx is probably not the right context to be using - my guess is that this creates a second canvas context that simply (no surprise!) overlays the main canvas. What is needed is a reference to the context of that main canvas.

So my question is: how can I access the context that is passed (as ctx) to draw() ? (The answer may be in the SDK manual, but I haven't been able to find it.)
B
105
S
20
G
12
Posts: 549
Reputation: 20,320

Post » Sun Sep 30, 2012 6:07 pm

The overlay context was removed recently. You should not use it - it was only ever there as a hack to support the Text object, and then when we implemented Text properly to avoid the hack the additional context was removed. You need to implement an actual WebGL drawing routine.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

Post » Sun Sep 30, 2012 6:56 pm

@Ashley
Thanks for your helpful reply - and for confirming my suspicions about the overlay context.
B
105
S
20
G
12
Posts: 549
Reputation: 20,320


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests