mirror of
https://github.com/liabru/matter-js.git
synced 2025-01-12 16:08:50 -05:00
Some fixes in pixi.js v3 update
This commit is contained in:
parent
419d2addca
commit
96735dd2c4
5 changed files with 14 additions and 14 deletions
|
@ -10,7 +10,7 @@
|
||||||
<script type="text/javascript" src="./js/lib/decomp.js"></script>
|
<script type="text/javascript" src="./js/lib/decomp.js"></script>
|
||||||
|
|
||||||
<!-- only required if using Matter.RenderPixi -->
|
<!-- only required if using Matter.RenderPixi -->
|
||||||
<script type="text/javascript" src="./js/lib/pixi.dev.js"></script>
|
<script type="text/javascript" src="./js/lib/pixi.js"></script>
|
||||||
|
|
||||||
<!-- matter lib edge master version -->
|
<!-- matter lib edge master version -->
|
||||||
<script type="text/javascript" src="./js/lib/matter-dev.js"></script>
|
<script type="text/javascript" src="./js/lib/matter-dev.js"></script>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="robots" content="noindex">
|
<meta name="robots" content="noindex">
|
||||||
|
|
||||||
<!-- only required if using Matter.RenderPixi -->
|
<!-- only required if using Matter.RenderPixi -->
|
||||||
<script type="text/javascript" src="./js/lib/pixi.dev.js"></script>
|
<script type="text/javascript" src="./js/lib/pixi.js"></script>
|
||||||
|
|
||||||
<!-- matter lib v0.8.0 -->
|
<!-- matter lib v0.8.0 -->
|
||||||
<script type="text/javascript" src="./js/lib/matter-0.8.0.js"></script>
|
<script type="text/javascript" src="./js/lib/matter-0.8.0.js"></script>
|
||||||
|
|
1
demo/js/lib/pixi.js.map
Normal file
1
demo/js/lib/pixi.js.map
Normal file
File diff suppressed because one or more lines are too long
|
@ -48,7 +48,6 @@ var RenderPixi = {};
|
||||||
// init pixi
|
// init pixi
|
||||||
render.context = new PIXI.WebGLRenderer(render.options.width, render.options.height, {
|
render.context = new PIXI.WebGLRenderer(render.options.width, render.options.height, {
|
||||||
view: render.canvas,
|
view: render.canvas,
|
||||||
autoResize: true,
|
|
||||||
transparent: transparent,
|
transparent: transparent,
|
||||||
antialias: true,
|
antialias: true,
|
||||||
backgroundColor: options.background
|
backgroundColor: options.background
|
||||||
|
@ -72,8 +71,8 @@ var RenderPixi = {};
|
||||||
render.primitives = {};
|
render.primitives = {};
|
||||||
|
|
||||||
// use a sprite batch for performance
|
// use a sprite batch for performance
|
||||||
render.bodies = new PIXI.Container();
|
render.spriteContainer = new PIXI.Container();
|
||||||
render.container.addChild(render.bodies);
|
render.container.addChild(render.spriteContainer);
|
||||||
|
|
||||||
// insert canvas
|
// insert canvas
|
||||||
if (Common.isElement(render.element)) {
|
if (Common.isElement(render.element)) {
|
||||||
|
@ -96,7 +95,7 @@ var RenderPixi = {};
|
||||||
*/
|
*/
|
||||||
RenderPixi.clear = function(render) {
|
RenderPixi.clear = function(render) {
|
||||||
var container = render.container,
|
var container = render.container,
|
||||||
bodies = render.bodies;
|
spriteContainer = render.spriteContainer;
|
||||||
|
|
||||||
// clear stage container
|
// clear stage container
|
||||||
while (container.children[0]) {
|
while (container.children[0]) {
|
||||||
|
@ -104,8 +103,8 @@ var RenderPixi = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear sprite batch
|
// clear sprite batch
|
||||||
while (bodies.children[0]) {
|
while (spriteContainer.children[0]) {
|
||||||
bodies.removeChild(bodies.children[0]);
|
spriteContainer.removeChild(spriteContainer.children[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var bgSprite = render.sprites['bg-0'];
|
var bgSprite = render.sprites['bg-0'];
|
||||||
|
@ -121,7 +120,7 @@ var RenderPixi = {};
|
||||||
container.addChildAt(bgSprite, 0);
|
container.addChildAt(bgSprite, 0);
|
||||||
|
|
||||||
// add sprite batch back into container
|
// add sprite batch back into container
|
||||||
render.container.addChild(render.bodies);
|
render.container.addChild(render.spriteContainer);
|
||||||
|
|
||||||
// reset background state
|
// reset background state
|
||||||
render.currentBackground = null;
|
render.currentBackground = null;
|
||||||
|
@ -232,7 +231,7 @@ var RenderPixi = {};
|
||||||
for (i = 0; i < constraints.length; i++)
|
for (i = 0; i < constraints.length; i++)
|
||||||
RenderPixi.constraint(engine, constraints[i]);
|
RenderPixi.constraint(engine, constraints[i]);
|
||||||
|
|
||||||
context.render(container); // render just render.bodies?
|
context.render(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -303,15 +302,15 @@ var RenderPixi = {};
|
||||||
if (bodyRender.sprite && bodyRender.sprite.texture) {
|
if (bodyRender.sprite && bodyRender.sprite.texture) {
|
||||||
var spriteId = 'b-' + body.id,
|
var spriteId = 'b-' + body.id,
|
||||||
sprite = render.sprites[spriteId],
|
sprite = render.sprites[spriteId],
|
||||||
bodies = render.bodies;
|
spriteContainer = render.spriteContainer;
|
||||||
|
|
||||||
// initialise body sprite if not existing
|
// initialise body sprite if not existing
|
||||||
if (!sprite)
|
if (!sprite)
|
||||||
sprite = render.sprites[spriteId] = _createBodySprite(render, body);
|
sprite = render.sprites[spriteId] = _createBodySprite(render, body);
|
||||||
|
|
||||||
// add to scene graph if not already there
|
// add to scene graph if not already there
|
||||||
if (Common.indexOf(bodies.children, sprite) === -1)
|
if (Common.indexOf(spriteContainer.children, sprite) === -1)
|
||||||
bodies.addChild(sprite);
|
spriteContainer.addChild(sprite);
|
||||||
|
|
||||||
// update body sprite
|
// update body sprite
|
||||||
sprite.position.x = body.position.x;
|
sprite.position.x = body.position.x;
|
||||||
|
@ -369,7 +368,7 @@ var RenderPixi = {};
|
||||||
* @param {body} body
|
* @param {body} body
|
||||||
* @return {PIXI.Graphics} graphics
|
* @return {PIXI.Graphics} graphics
|
||||||
*/
|
*/
|
||||||
var _createBodyPrimitive = function(render, body) { // TODO: use canvas to create sprite, not PIXI.Graphics
|
var _createBodyPrimitive = function(render, body) {
|
||||||
var bodyRender = body.render,
|
var bodyRender = body.render,
|
||||||
options = render.options,
|
options = render.options,
|
||||||
primitive = new PIXI.Graphics(),
|
primitive = new PIXI.Graphics(),
|
||||||
|
|
Loading…
Reference in a new issue