Spriteset_Map.prototype.createLighting = function() {
$gameLighting.clear();
this._lightingTexture = PIXI.RenderTexture.create(LightingSurface.getRecommendedWidth(), LightingSurface.getRecommendedHeight());
this._lightingSurface = new LightingSurface();
this._lightingSprite = new PIXI.Sprite();
this._lightingSprite.texture = this._lightingTexture;
this._lightingSprite.blendMode = PIXI.BLEND_MODES.MULTIPLY;
this._lightingSprite.alpha = 1.0;
this.addChild(this._lightingSprite);
};
Spriteset_Map.prototype.updateLighting = function() {
this._lightingSurface.update();
Graphics._renderer.render(this._lightingSurface, this._lightingTexture, false);
};
function LightingSurface() {
this.initialize.apply(this, arguments);
}
LightingSurface.prototype = Object.create(PIXI.Container.prototype);
LightingSurface.prototype.constructor = LightingSurface;
LightingSurface.getRecommendedWidth = function() {
var scale = 1 / $gameScreen.zoomScale();
return Graphics.width * (scale + 0.5);
};
LightingSurface.getRecommendedHeight = function() {
var scale = 1 / $gameScreen.zoomScale();
return Graphics.height * (scale + 0.5);
};
LightingSurface.prototype.initialize = function() {
PIXI.Container.call(this);
this._width = LightingSurface.getRecommendedWidth();
this._height = LightingSurface.getRecommendedHeight();
this.position.set(Graphics.width - this._width / 2, 0);
this._createSurface();
};
LightingSurface.prototype._createSurface = function() {
this._surface = new Sprite(); // This is the part that is misplaced, I guess
this._surface.bitmap = new Bitmap(this._width, this._height);
var color = GameEditor.rgbToHex($gameTime.tint(0), $gameTime.tint(1), $gameTime.tint(2));
this._lastColor = color;
this._surface.bitmap.fillAll(color);
this.addChild(this._surface);
};