jCanvas

For developers using the Construct 2 Javascript SDK

Post » Fri Feb 03, 2012 2:50 am

http://calebevans.me/projects/jcanvas/index.php
I would like to use jCanvas to draw shapes at both edit time and run time. I tried just copying and pasting the minified code into the common.js file, but got this error:
---------------------------
HTML5 exporter
---------------------------
Unable to load plugin in 'C:\Program Files\Construct 2\exporters\html5\plugins\zui_rectangle\': Javascript exception in file 'common.js' line 8: ReferenceError: jQuery is not defined

Code line:
tContext!=null);r(d);A.defaults=p;A.prefs=j;A.extend=B;k.jCanvas=A}(jQuery,doc

Stack trace:
ReferenceError: jQuery is not defined
    at common.js:8:12841

This plugin will not be available in the editor.
---------------------------
OK   
---------------------------
            

How would I get jCanvas to work?
B
25
S
8
G
8
Posts: 71
Reputation: 5,307

Post » Fri Feb 03, 2012 4:03 am

It sounds like some kind of reference to jQuery gets passed as a parameter there, and I believe C2 object sealing prevents the usage that is done in the library you add.
It's a wild guess, but I believe posting the whole files would help to make sure the integration was made correctly.
More about object sealing and jQuery usage in the SDK.

As a solution, you might also want to take a look at R0j0hound's canvas plugin which should allow you drawing of basic shapes as you're aiming for.
I'm not sure it's a jCanvas (more like a regular <canvas>) but it should do the trick.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Fri Feb 03, 2012 3:07 pm

You cannot use browser technologies like jCanvas to render in the edittime. The edittime is a pure javascript context - there is no browser, DOM, window, document or anything, nor can you create canvases, divs or anything like that. For that reason, there's also no jQuery in the edittime scripts. jQuery is only provided for the runtime scripts.

So pasting code using a browser or jQuery in to common.js will also paste it in to edittime.js where it won't work. Just paste it in to runtime.js.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Fri Feb 03, 2012 3:49 pm

Ok then, how can I render rounded rectangles, gradients, and outlines with a thickness other than 1px in edit time?
B
25
S
8
G
8
Posts: 71
Reputation: 5,307


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 1 guest