mirror of
https://github.com/wassname/phaser.git
synced 2026-08-09 12:20:34 +08:00
Fixed issue in Camera.inCamera check where it wouldn't take into consideration the Sprites scrollFactor.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/// <reference path="../Game.ts" />
|
||||
/// <reference path="../core/Point.ts" />
|
||||
/// <reference path="../core/Rectangle.ts" />
|
||||
/// <reference path="../core/Circle.ts" />
|
||||
|
||||
/**
|
||||
* Phaser - PixelUtils
|
||||
*
|
||||
* A collection of methods useful for manipulating pixels.
|
||||
*/
|
||||
|
||||
module Phaser {
|
||||
|
||||
export class PixelUtils {
|
||||
|
||||
static boot() {
|
||||
|
||||
PixelUtils.pixelCanvas = <HTMLCanvasElement> document.createElement('canvas');
|
||||
PixelUtils.pixelCanvas.width = 1;
|
||||
PixelUtils.pixelCanvas.height = 1;
|
||||
PixelUtils.pixelContext = PixelUtils.pixelCanvas.getContext('2d');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Canvas element used in 1x1 pixel checks.
|
||||
* @type {HTMLCanvasElement}
|
||||
*/
|
||||
static pixelCanvas: HTMLCanvasElement;
|
||||
|
||||
/**
|
||||
* Render context of pixelCanvas
|
||||
* @type {CanvasRenderingContext2D}
|
||||
*/
|
||||
static pixelContext: CanvasRenderingContext2D;
|
||||
|
||||
static getPixel(key: string, x: number, y: number): number {
|
||||
|
||||
// write out a single pixel (won't help with rotated sprites though.. hmm)
|
||||
|
||||
var imageData = PixelUtils.pixelContext.getImageData(0, 0, 1, 1);
|
||||
|
||||
return ColorUtils.getColor32(imageData.data[3], imageData.data[0], imageData.data[1], imageData.data[2]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user