ninemind Posted April 1, 2014 Share Posted April 1, 2014 If I have an array of x,y points, how can I draw a shape on the canvas that passes through those points either as straight lines or curves and also use it as a collision shape. These shapes may not always be solid. For example I might draw a shape that looks like the letter "A" where there is a triangle hole in the shape who's borders will have collision. Quote Link to comment Share on other sites More sharing options...
ninemind Posted April 2, 2014 Author Share Posted April 2, 2014 I have figured out how to draw custom shapes and even turn those shapes into sprites using PIXI.Graphics(). I'm still unsure how to make a collision shape that matches the shape I drew though. Anybody? Quote Link to comment Share on other sites More sharing options...
enpu Posted April 2, 2014 Share Posted April 2, 2014 I assume that you are using p2 physics? You should take a look at p2 demos/docs and see if you can figure that out:https://github.com/schteppe/p2.js I have not yet myself used p2 physics with polygon shapes. Quote Link to comment Share on other sites More sharing options...
ninemind Posted April 2, 2014 Author Share Posted April 2, 2014 I will be using p2.js physics later on in development. Are Panda.js collision shapes not compatible with p2.js? Quote Link to comment Share on other sites More sharing options...
enpu Posted April 2, 2014 Share Posted April 2, 2014 Panda physics only support rectangle and circle shapes, and those are not compatible with p2. So you should really start using p2 if you need more advanced physics in your game. Quote Link to comment Share on other sites More sharing options...
ninemind Posted April 2, 2014 Author Share Posted April 2, 2014 I think I figured out how to create complex collision shapes with p2.js using p2.Convex() but I'm having trouble displaying the shape on the Panda.js canvas with DebugDraw. I am using the Panda.js files from the development branch as well as p2.js from your plugins on github but I see nothing being displayed. Even with simple p2.Circle's or p2.Rectangle's I see nothing. Quote Link to comment Share on other sites More sharing options...
brianbrown Posted July 25, 2014 Share Posted July 25, 2014 Sorry to bring up an old topic, but how did you manage to draw shapes with PIXI.Graphics? I've looked through the source code, but I can't get it to work. Quote Link to comment Share on other sites More sharing options...
enpu Posted July 27, 2014 Share Posted July 27, 2014 Simple example on using Graphics:var grap = new game.Graphics();grap.beginFill(0xffffff);grap.drawRect(0, 0, 100, 100);grap.position.set(200, 200);grap.addTo(this.stage);http://www.goodboydigital.com/pixijs/docs/classes/Graphics.html gaelbeltran 1 Quote Link to comment Share on other sites More sharing options...
brianbrown Posted July 28, 2014 Share Posted July 28, 2014 Thank you enpu! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.