Jump to content

Bitmapdata at x and y position


proyb2
 Share

Recommended Posts

How is bmd2 can be move to x and y position?
var createBox = game.make.bitmapData(100,6)createBox.fill(0,0,0,1)createBox.addToWorld() //At 0,0var bmd2 = game.make.bitmapData(1,1)var rect = new Phaser.Rectangle(0,0,1,1)bmd2.copyRect(createBox.canvas,rect)//orbmd2.copy(createBox.canvas,100,100,20,100) //Don't seem to able to move to x:100px and y:100px position?

 

Link to comment
Share on other sites

If you look at the method signature for copy you'll see the first few parameters are where to copy from (not to).

 

For this example specifically I'd just do:

var bmd2 = game.make.bitmapData(1,1)var rect = new Phaser.Rectangle(0,0,1,1)bmd2.copyRect(createBox.canvas,rect, 100, 100)
Link to comment
Share on other sites

  • 1 year later...

On the topic, I have my bitmap data added to my world as you've shown:

bmd2.addToWorld(100, 100);

But, now I need to reposition my bitmap data within my world. How do I change the x/y position after it's been added to the world?

Link to comment
Share on other sites

I noticed 

move(x, y, wrap)

I assumed that the method moved the bitmap the amount of x and y relative to the bitmap's current location, but I'm going to give this a try and see if it works relative to the top left of the world.

 

EDIT

Quote

The amount of pixels to horizontally shift the canvas by. Use a negative value to shift to the left, positive to the right.

This seems to indicate that the x and y are relative to the current location..

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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