liabru / matter-js

a 2D rigid body physics engine for the web ▲● ■
MIT License
16.86k stars 1.97k forks source link

failed with documentation code... #972

Closed jyeann closed 3 years ago

jyeann commented 3 years ago

1st time testing here and tried testing out the demo code in getting start, but it kept showing matter-js: Render.create: options.element was undefined, render.canvas was created but not appended warn

`<!DOCTYPE html>

Document

`

michael-garofalo commented 3 years ago

Where did you see this documentation?

It looks similar to this... https://github.com/liabru/matter-js/wiki/Getting-started ...and that works for me, because I used a slightly modified version to help troubleshoot an issue here... https://github.com/liabru/matter-js/issues/256#issuecomment-752126652

matterjs-comparison

It looks like there's an extra comma. Maybe that's a problem?

francoispeyret commented 3 years ago

@michael-garofalo your remark seems to be the right one

jyeann commented 3 years ago

@liabru yes, is the exact getting started code.

tried, but still empty when load browser

tried you #256 (comment) code. still blank browser

michael-garofalo commented 3 years ago

tried you #256 (comment) code. still blank browser

Usually, when something like this happens, I open up the developer tools in the browser. Which browser are you using? Typically, there's a console log message that says what's wrong.

The HTML, in issue #256, is not enough. It needs the matter.min.js file too.

<script src="matter.min.js"></script>


I just tested the code and I was like... WTF?! It's blank. 😄

But, upon closer inspection, the page wasn't blank. There was a scrollbar. I was able to scroll the page and then see the demo at the bottom. I don't remember it doing that before. The problem is this...

     <div style="width:100%; height: 100%;">
     </div>

I just removed that part and it seems to be working normally.

jyeann commented 3 years ago

Thank you, i got it.

some how replaced the source files, the browser show the output.

Regards

'Jyeann Hp +6012 370 7373 Connecting https://www.linkedin.com/in/jye-ann-a4b4333a Creativity https://www.linkedin.com/in/jye-ann-a4b4333a

Design • Trading • Technology

On Mon, Mar 1, 2021 at 8:32 PM michael-garofalo notifications@github.com wrote:

tried you #256 https://github.com/liabru/matter-js/issues/256 (comment) code. still blank browser

Usually, when something like this happens, I open up the developer tools in the browser. Which browser are you using? Typically, there's a console log message that says what's wrong.

The HTML, in issue #256 https://github.com/liabru/matter-js/issues/256, is not enough. It needs the matter.min.js file too.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/liabru/matter-js/issues/972#issuecomment-787914134, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA254O2CGM7F6MC7TPTQVHLTBOCOVANCNFSM4XJYTVPA .

bohemian916 commented 2 years ago

I also faced the same error. It was because I loaded the script in the head section. Instead, I load in the body section, and no error appeared.