fabriziof64 Posted June 5, 2014 Share Posted June 5, 2014 Hi, I'm working on a web app that receives jpg images from the server, and I need to resize the received image to the size of a mask .png image.I'm trying as follows, but I don't find the way to scale the image that I get from the cache.Can anyone help me? Thanks, // get the size of the mask .png image herevar maskImage = game.cache.getImage('mainMask'); // make a bitmapData with that sizevar bmd = game.make.bitmapData(maskImage.width, maskImage.height); // get the image received from the server that must be maskedvar currImage = game.cache.getImage(cacheKey); // ======>>>>>>> scale / resize / crop the currImage here to match the mask image size, and put the result into the cache // apply maskbmd.alphaMask(cacheKey, 'mainMask'); // create the spritevar sprite = game.add.sprite(game.rnd.integerInRange(maskImage.width / 2, 1000), game.rnd.integerInRange(maskImage.height / 2, 1000), bmd); Link to comment Share on other sites More sharing options...
Recommended Posts