Jump to content

Search the Community

Showing results for tags 'p2 addpolygon body custom shape'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 1 result

  1. i'll go straight to the point since it's my very first post on the forum and it's almost eve.. I'm using phaser 2.6.2, and p2 engine. I have a simple rectangular sprite obtained via a graphics object, using drawRect and then generating the texture for the sprite.. nothing fancy.. On this object i need a p2 body.. 1) the classical way ( works as a charm) enabling the p2 body on the sprite, generating a "body.data.shapes" of "Box" (2 triangles), the result is a pixel perfect shape overlapping the original one BUT i was thinking.. <<since i will have a lot of these small simple rectangles on the scene, to spare some computation to the p2 engine i could cut the "Box" (2 triangles) default mode, on a single triangle one.. 2) so i've used "body.clearShapes" method first, and then applied the newly desired triangle coordinates with the "body.addPolygon" method.. and there's my problem... with the body debug enabled i can clearly see the new triangle, tracing the object in the console i can also notice that "body.data.shapes" now it's "Convex" and there's just a triangle in the array.. so it would be perfect for my needs.. but the new body now is shifted of some pixels toward the positive x axis and that's useless this way.. double checked the code, there are no errors in that.. i have to admit i don't have already checked the source code of the "body.addPolygon" to see why giving odd sided shapes to the method will generate the shifting... anyway.. i wanted to hear from you guys what you think the problem is first, i'll post the code i used, and an image showing a default body applied on the rectangular shape (on top of the image) and my triangle one via "body.addPolygon" (on the bottom of the image) where u could appreciate the x shifting .. mySprite.body.clearShapes(); // to clean the box default mySprite.body.addPolygon( { skipSimpleCheck : true }, // options [[0, 0], [0, mySprite.height], [mySprite.width, mySprite.height / 2]]); the image (default Box model on top, custom "triangle" body via addPolygon, on bottom) .. you can clearly see the x shifting ... http://imgur.com/w7tjJXz Thx for the time spent reading the poem and i will wait your considerations on the matter...
×
×
  • Create New...