Jump to content

1968 game + canvas question


PunyOne
 Share

Recommended Posts

So I finished a game that originated at a Jam with the topic "Russian Invasion".

You can play it here: http://www.justaconcept.org/Games/1968/index.html .

A tiny screenshot: 

1968.jpeg

With that I have a little question, I tried to position the game inside my page as you can see, but I had trouble that PandaJS takes the canvas it is put in and places it to it's own preferred coordinates. I achieved the above effect by explicitly removing the absolute positioning from the engine source, but that's quite a hack. 

Basically what I need is for panda to position the canvas w.r.t. its parent (e.g. a <div>) instead of the whole window. Any suggestions?

Link to comment
Share on other sites

Try to disable centering:

 

game.System.center = false;

Thanks for reply but it does not help - when I set the above, it puts the canvas to the topleft corner of the whole page, so it lies over the buttons and others.

I tried all the combinations of the System parameters I could find, without success.

Link to comment
Share on other sites

Hmm, try to put your canvas inside div, like:

<div id="myDiv">    <canvas id="myCanvasId"></canvas></div>

Then tell Panda to use that canvas, by giving it's id:

game.start(SceneStart, 1024, 768, null, 'myCanvasId');

or use game.System.canvasId property (latest develop version).

Link to comment
Share on other sites

Hmm, try to put your canvas inside div, like:

<div id="myDiv">    <canvas id="myCanvasId"></canvas></div>

Then tell Panda to use that canvas, by giving it's id:

game.start(SceneStart, 1024, 768, null, 'myCanvasId');

 

That is exactly what I have in the code (you can check it on the page, the canvasId is "1968_canvas").

I can see that it is in the canvas because it moves the frame of the canvas too (I used blue frame in the debug and I clearly saw that the frame got moved to the topleft corner).

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...