Problems importing library

15 views
Skip to first unread message

Daniel Ohuruogu

unread,
Apr 29, 2018, 10:24:54 AM4/29/18
to Processing.js
Hi guys,

I want to use Box2D for processing.js for a school project, but I've having problems importing the library. I've created a custom template with the box2d-min.js copied in locally and referenced in the document's HTML file, but for some reason example scripts do not run.

I'm also having problems with the script itself. I ran the simplebox2D example that comes with processing without any problems.The second I copy and paste it into a new processing.js file though, the script no longer runs, with the console saying 'badly formed character constant (expecting quote, got b). How could this be if I copied and pasted everything exactly, except for a different file path?

Any help would be greatly appreciated - it's frustrated me for two days.

Thanks in advance
Daniel

Lee Brunjes

unread,
Apr 29, 2018, 10:36:10 AM4/29/18
to proces...@googlegroups.com

Typically these things come from a couple problems:
1. You are not using correct paths. In this case you should see an error in the network tab of your browser, you should be able to see what status code and actuakl text you got when loading the box2d file
2. you are trying to access a file:url and processing.js uses xmlhttprequest under the hood. Most browsers block this action. Solutions are to either use a web server 

In both cases check the network tab of your browsers dev tools and you should get a pretty good idea which issue you have.

If that doesn't help, please post some example code and we can go forward form there.

-Lee


--
You received this message because you are subscribed to the Google Groups "Processing.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to processingjs+unsubscribe@googlegroups.com.
To post to this group, send email to proces...@googlegroups.com.
Visit this group at https://groups.google.com/group/processingjs.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Daniel Ohuruogu

unread,
Apr 29, 2018, 2:33:02 PM4/29/18
to Processing.js
Hi Lee,

Thanks for the response.

1. I've followed the steps from this website http://box2d-js.sourceforge.net/. Surely if I've done everything here and copied and pasted in the sample code, it should work OK? What other steps are there to take?
Also, how would this apply to the example packaged in with Processing.js where the library is stored locally in a data file and referenced in the script itself?

2. I've copied and pasted sample code from one Processing.js file to another new file - all it is is a change in file path, not a change in programme or web server. How could processing then tell me there's a syntax error?

Sorry if these are simple questions to answer. It's all really confusing and frustrating, seeing as there's a deadline for a project I can't even get off the ground. Is there something different that has to be done for each example I've cited, seeing as they're doing the same thing but from different angles? For some reason I don't think I can attach a zip file with the example, but it's in the programme's files under C:\Users\Documents\Processing\modes\JavaScriptMode\examples\Libraries


On Sunday, 29 April 2018 15:36:10 UTC+1, Lee wrote:

Typically these things come from a couple problems:
1. You are not using correct paths. In this case you should see an error in the network tab of your browser, you should be able to see what status code and actuakl text you got when loading the box2d file
2. you are trying to access a file:url and processing.js uses xmlhttprequest under the hood. Most browsers block this action. Solutions are to either use a web server 

In both cases check the network tab of your browsers dev tools and you should get a pretty good idea which issue you have.

If that doesn't help, please post some example code and we can go forward form there.

-Lee

On Fri, Apr 27, 2018 at 11:04 AM, Daniel Ohuruogu <daniel....@hotmail.co.uk> wrote:
Hi guys,

I want to use Box2D for processing.js for a school project, but I've having problems importing the library. I've created a custom template with the box2d-min.js copied in locally and referenced in the document's HTML file, but for some reason example scripts do not run.

I'm also having problems with the script itself. I ran the simplebox2D example that comes with processing without any problems.The second I copy and paste it into a new processing.js file though, the script no longer runs, with the console saying 'badly formed character constant (expecting quote, got b). How could this be if I copied and pasted everything exactly, except for a different file path?

Any help would be greatly appreciated - it's frustrated me for two days.

Thanks in advance
Daniel

--
You received this message because you are subscribed to the Google Groups "Processing.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to processingjs...@googlegroups.com.

Lee Brunjes

unread,
Apr 29, 2018, 8:02:02 PM4/29/18
to proces...@googlegroups.com
Taking a look at the box 2d library you linked, it does not appear to be a processing library at all, its a decade old port of the java library to js with a stop in flash along the way.

There is a more recently updated library here that claims to work with processing as of 2015.


Their page links to various bits but hopefully that will make things better for you going forward.

-Lee


To unsubscribe from this group and stop receiving emails from it, send an email to processingjs+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages