RPG Maker Forums

Hello !

I have a PIXI.Container supposed to fill the whole screen, but if you zoom out the screen with, for example, SRD's plugin, or use the shake function, it happens that it won't fit the whole screen. I found a solution for that, but there is a problem : when using this.position.set(x, y) with x and y being negative, the PIXI.Container won't move an inch, it will just stay at the same position.

I tried to put positive coordinates to make sure the problem didn't come from the position not taken in account, and the Container moved just as intended. So the problem really comes from coordinates.

What happens is that the (0,0) position is not the top left corner of the screen if you have a map wide enough and a scale between 0 and 1 exclusive.

So my question is how to make the Container take negative coordinates to move it to the left, or is there a way to say to the container to start at the top left corner of the map? (like the top left corner of the case in (0,0).

Thanks for your time and your answer ^^

EDIT: Here's the code :

Code:
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);
};

Latest Threads

Latest Profile Posts

Day 9 of giveaways! 8 prizes today :D
He mad, but he cute :kaopride:

Our latest feature is an interview with... me?!

People4_2 (Capelet off and on) added!

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.

Forum statistics

Threads
106,038
Messages
1,018,466
Members
137,821
Latest member
Capterson
Top