bitmaps over a sprite

Recommended Posts

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



keep in mind that the sprite will be moving around, is there a easiest way to do this?



Share this post

Link to post
Share on other sites

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).

Share this post

Link to post
Share on other sites

ok i followed your advice but now im facing problems with the position:


    bmd = game.add.bitmapData(200,500);
    bmd.y = 100;
    bmd.x = 100;
    nuevodiskette = game.add.sprite(0,0,bmd);
    nuevodiskette.anchor.setTo(0.5, 0.5);



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(  - bmd.x  );
           var y = Math.floor(  - 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


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.