Jump to content

Resize a bitmapdata using scaleMode RESIZE


jdnichollsc
 Share

Recommended Posts

not sure what you need to do with the RESIZE scaleMode, but this is how to resize an image to a new bitmap

http://phaser.io/sandbox/DoAbtYim/play

 

could you elaborate on what you need?

 

function create() {    var map = game.make.sprite(0,0,'map')        var w = map.width    var h = map.height        console.log(w,h) // => 1500,843        var ratio = w/h        // let's make a new map image, 300 high    var newW = 300*ratio    var newH = 300        // create a bitmap data at our new size and draw the map to it    // this draw() function resizes the source to the new dimensions    var bmp = game.add.bitmapData(newW, newH)    bmp.draw(map,0,0,newW, newH)    // show the bitmap data    var sprite = game.add.sprite(0,0, bmp)    sprite.anchor.set(0.5,0.5)    sprite.x=400    sprite.y=300}
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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