pranadevil Posted March 15, 2016 Share Posted March 15, 2016 hello im just wondering if i can cover a sprite with a bitmap, think about a character and covering it with clothes(bitmaps) i tried adding them as a child sprite1.addChild(bitmap); keep in mind that the sprite will be moving around, is there a easiest way to do this? Link to comment Share on other sites More sharing options...
stupot Posted March 15, 2016 Share Posted March 15, 2016 When you say 'bitmap' do you mean a Phaser BitmapData object? If yes, then you need to make a sprite or image using this, then you can add that image/spriteas a child to sprite1 just like as you have tried. If sprite1 is moving around then the child will move with it because it is positioned relative to its parent (sprite1). Link to comment Share on other sites More sharing options...
pranadevil Posted March 15, 2016 Author Share Posted March 15, 2016 ok i followed your advice but now im facing problems with the position: bmd = game.add.bitmapData(200,500); bmd.load('nnnn'); bmd.update(); bmd.y = 100; bmd.x = 100; nuevodiskette = game.add.sprite(0,0,bmd); nuevodiskette.anchor.setTo(0.5, 0.5); game.physics.arcade.enable(nuevodiskette); /////////// sheep1.addChild(nuevodiskette); if i want to check if the mouse pointer is inside the bitmap what should i use? i tried if (game.input.activePointer.isDown ){ var x = Math.floor(this.game.input.x - bmd.x ); var y = Math.floor(this.game.input.y - bmd.y ); but it seems to be an offset, when i click for example (100,100) when bitmaps is at 100,100 too, the hole seems to be upper, not exactly at mouse x and y why? Link to comment Share on other sites More sharing options...
Recommended Posts