Matthias Elephant Posted February 29, 2016 Share Posted February 29, 2016 Hi, how can i create a sprite, that don't use the displayobject "Rectangle". I want to use the displayobject "circle". Thanks Link to comment Share on other sites More sharing options...
iKest Posted February 29, 2016 Share Posted February 29, 2016 You can make a sprite from any figure , but his physical body will by rectangle. Link to comment Share on other sites More sharing options...
Matthias Elephant Posted February 29, 2016 Author Share Posted February 29, 2016 Hmmm, but i need a sprite that returns a Phaser.Circle if i call sprite.getBounds() (i always get the Rectangle). Then i can check, if two circles are overlaped to another. I can't use a physics body because my sprite is a children of another sprite and this didn't work. Now i'm looking for a workaround without physics. But this just works if i have a sprite with displayobject 'circle'. Thanks Link to comment Share on other sites More sharing options...
iKest Posted February 29, 2016 Share Posted February 29, 2016 Circle not display.object, is just graphics wihtout bounds. Link to comment Share on other sites More sharing options...
Matthias Elephant Posted February 29, 2016 Author Share Posted February 29, 2016 Ok then i misunderstand the documentation. Alternative: It is possible to make the Rectangle (that i get at "sprite.getBounds()" ) smaller? Sprite.scale is not that what i'm looking for. The visual component that the user see, should be the same size as before. Only the "physical" rectangle should be smaller for a better "overlap" of two circles. Link to comment Share on other sites More sharing options...
iKest Posted February 29, 2016 Share Posted February 29, 2016 Make phisical body for parent sprite with offset to you circle.sprite. You can also use circle body with ninja physics. Link to comment Share on other sites More sharing options...
Matthias Elephant Posted February 29, 2016 Author Share Posted February 29, 2016 Thanks for all you answers. I already use the p2 physics engine (need polygons some some sprites). In following example i have a two sprites. A parent and a children. The children is a circle, but the positioning didnt work. Just copy my following example code to: http://phaser.io/examples/v2/p2-physics/basic-movement#gv var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); function preload() { game.load.image('atari', 'assets/sprites/atari130xe.png'); } var sprite; var children; function create() { game.physics.startSystem(Phaser.Physics.P2JS); children = game.add.sprite(100, 100, 'atari'); children.scale.set(0.5); game.physics.p2.enable(children, true); children.body.setZeroDamping(); children.body.moveRight(10); children.body.setCircle(30); sprite = game.add.sprite(200, 200, 'atari'); game.physics.p2.enable(sprite, true); sprite.body.setZeroDamping(); sprite.body.moveRight(10); //sprite.body.rotateLeft(10); sprite.addChild(children); } function update() { } Thanks for any help! Link to comment Share on other sites More sharing options...
Recommended Posts