Search the Community
Showing results for tags 'addpolygon'.
-
Hello, everybody! As usually, I'm a newbie in Phaser and JS (and English, as well) :-) Now I'm trying to achieve this approach in Phaser-CE 2.7.8. Slow spinning wheel (actually N-gon, with 12 sides for now) shuffling bunch of balls (30-50) inside of it. When the hole on the wheel's edge reaches some bottom point one ball must fall out (random bal, with random number on it, got from the server. I don't know yet how much sides the wheel will be, and to apply same polygon to p2.body.polygon I put all the points into array (lines).Next I rearrange lines and it's directions to form "seamless polygon": end point of one line is start point of next line. And here I faced first problem: last line not drawn (top left green line). This poly drawn at line 85. But in the console log i can see that line coords! Second problem: adding sprite converted from graphics (via generateTexture()) and putting at specified coords work well, but if I uncomment sprite.body.addPoligon at line 93, sprite moved across X and Y axis, looks little thicker, and body(.addPolygon) not collinear with a sprite! May be I'm completely wrong and that wheel can be made much easier? Here is my code: http://phaser.io/sandbox/tkSaOlQd
-
- p2
- drawpolygon
-
(and 2 more)
Tagged with:
-
Hello, I have a problem when I use addPolygon. Polygon change position image. When I turn on debug I see images, and new shape draw in center. Second problem I don't now why image and shape Polygon is different. How fix this problem ? I not seen problem when I use addRectangle. Image and new shape is corect in tile 70px x 70px. Code: function create() { ... groups.tile = game.add.group(); groups.tile.enableBody = true; groups.tile.enableBodyDebug = true; groups.tile.physicsBodyType = Phaser.Physics.P2JS; groups.tile.collideWorldBounds = false; ... var obj = groups.tile.create((x * map.width) - (map.width / 2), (y * map.height) - (map.height / 2), spriteName, numberTile); obj.body.static = true; obj.body.fixedRotation = true; obj.body.collideWorldBounds = true; obj.body.clearShapes(); var myPolygonArray= [ [0,0], [0,70], [70,70], [70,46], [25,46], [25,0]]; obj.body.addPolygon({}, myPolygonArray); } Example:
- 1 reply
-
- phaser
- addPolygon
-
(and 1 more)
Tagged with: