proyb2 Posted January 28, 2015 Share Posted January 28, 2015 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 More sharing options...
rich Posted January 28, 2015 Share Posted January 28, 2015 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 More sharing options...
proyb2 Posted January 28, 2015 Author Share Posted January 28, 2015 I see and the position is still at 0,0 despite change with the code below.bmd2.copyRect(createBox.canvas,rect, 100, 100) Link to comment Share on other sites More sharing options...
rich Posted January 28, 2015 Share Posted January 28, 2015 Position of what? bmd2 within createBox, or createBox in the world? Link to comment Share on other sites More sharing options...
proyb2 Posted January 28, 2015 Author Share Posted January 28, 2015 To set the position of x and y bmd2 in game world. Link to comment Share on other sites More sharing options...
rich Posted January 28, 2015 Share Posted January 28, 2015 But bmd2 hasn't been added to the game world. It's just a 1x1 bitmapData. If you want it to appear in the game world then it needs adding:bmd2.addToWorld(100, 100); Link to comment Share on other sites More sharing options...
proyb2 Posted January 29, 2015 Author Share Posted January 29, 2015 Maybe you may try on JSFiddle? I think there is a bug that bmd2 isn't showing after bmd2.addToWorld Link to comment Share on other sites More sharing options...
rich Posted January 29, 2015 Share Posted January 29, 2015 You create one, I'll review it. As far as I can see from the above you've a 1x1 transparent pixel somewhere on screen. Good luck finding it Link to comment Share on other sites More sharing options...
vspinnet Posted April 23, 2016 Share Posted April 23, 2016 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 More sharing options...
vspinnet Posted April 23, 2016 Share Posted April 23, 2016 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 More sharing options...
rich Posted April 23, 2016 Share Posted April 23, 2016 Look at the docs, specifically look at what BitmapData.addToWorld() returns. That should tell you all you need to know! vspinnet 1 Link to comment Share on other sites More sharing options...
vspinnet Posted April 23, 2016 Share Posted April 23, 2016 3 hours ago, rich said: Look at the docs, specifically look at what BitmapData.addToWorld() returns. That should tell you all you need to know! Thanks. Link to comment Share on other sites More sharing options...
Recommended Posts