/** * Generated from the Phaser Sandbox * * //phaser.io/sandbox/DoAbtYim * * This source requires Phaser 2.6.2 */ var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.baseURL = 'http://examples.phaser.io/assets/'; game.load.crossOrigin = 'anonymous'; game.load.image('phaser', 'sprites/phaser-dude.png'); // map game.load.image('map','http://i.imgur.com/SdaW1Gv.jpg') } function create() { //var sprite = game.add.sprite(0, 0, 'phaser'); 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 300 high var newW = 300*ratio var newH = 300 // create a bitmap data at our new size and draw the map to it // this resizes it 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 } function update() { } function render() { }