Jump to content

bitmaps over a sprite


pranadevil
 Share

Recommended Posts

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...