[solved] What cause Bitmap.snap to look weird in the battle scene

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
When you go to the menu, the game takes a picture of the map and uses it as a static background. It does the same thing when you go into a battle but you don't have a battleback set. On the menu scene it looks fine; the map looks exactly as it does before I open the menu.

However, the picture looks like it's scaled up a bit in the battle and I'm not sure why that happens.

Map tiles are 48x48 pixels. My is also 48x48. The picture of the map should basically align with the grid.

1597783593018.png

Code:
Spriteset_Battle.prototype.createBackground = function() {
    this._backgroundSprite = new Sprite();
    this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
    this._baseSprite.addChild(this._backgroundSprite);
};
The backgroundSprite is stored here.

Code:
SceneManager.snapForBackground = function() {
    this._backgroundBitmap = this.snap();
    // this._backgroundBitmap.blur();
  };
I also took out the blur.
 
Last edited:

Ossra

Formerly Exhydra
Veteran
Joined
Aug 21, 2013
Messages
1,076
Reaction score
854
First Language
English
Primarily Uses
RMMV
Hmm, perhaps it is scaled up somewhere along the line to account for the screen shake? So that the black edges do not show?
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,545
Reaction score
3,715
First Language
Java's Crypt
Primarily Uses
RMMZ
The menu adds the background as a direct child, while the battle add it as a child of baseSprite. Maybe there's some manipulation on this baseSprite? I noticed it has a tone filter in it but didn't see anything related to size.
 

ct_bolt

Creator
Veteran
Joined
May 3, 2012
Messages
954
Reaction score
520
First Language
Javascript
Primarily Uses
RMMZ
Here this should fix it...

Code:
Scene_Map.prototype.launchBattle = function() {
    BattleManager.saveBgmAndBgs();
    this.stopAudioOnBattleStart();
    SoundManager.playBattleStart();

    // Hide characters and desinationSprite
    this._spriteset.hideCharacters();
    this._spriteset._destinationSprite.visible = false;

    // Snap for BattleBG
    this.snapForBattleBackground();

    // Start encounter as normal
    this.startEncounterEffect();
    this._mapNameWindow.hide();
};

// Overwrite to remove snapforBattleBackground
Scene_Map.prototype.updateEncounterEffect = function() {
    if (this._encounterEffectDuration > 0) {
        this._encounterEffectDuration--;
        var speed = this.encounterEffectSpeed();
        var n = speed - this._encounterEffectDuration;
        var p = n / speed;
        var q = ((p - 1) * 20 * p + 5) * p + 1;
        var zoomX = $gamePlayer.screenX();
        var zoomY = $gamePlayer.screenY() - 24;
        if (n === 2) {
            $gameScreen.setZoom(zoomX, zoomY, 1);

            // Removed snapForBattleBackground
            // this.snapForBattleBackground();

            this.startFlashForEncounter(speed / 2);
        }
        $gameScreen.setZoom(zoomX, zoomY, q);
        if (n === Math.floor(speed / 6)) {
            this.startFlashForEncounter(speed / 2);
        }
        if (n === Math.floor(speed / 2)) {
            BattleManager.playBattleBgm();
            this.startFadeOut(this.fadeSpeed());
        }
    }
};

Look ok?
1597785857523.png
Basically overwrites to Scene_Map.prototype.launchBattle & Scene_Map.prototype.updateEncounterEffect seem to solve the issue.

Instead of taking a snapshot during the EncounterEffect, I changed it to take a snapshot before the effect during the launchBattle function :)
 

Attachments

Last edited:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
Hmm, perhaps it is scaled up somewhere along the line to account for the screen shake? So that the black edges do not show?
Oh, it is that screen shake Along with zooming. Cause like @ct_bolt found the screen gets zoomed during encounter transition...

Code:
Spriteset_Base.prototype.updatePosition = function() {
    var screen = $gameScreen;
    var scale = screen.zoomScale();
    this.scale.x = scale;
    this.scale.y = scale;
    this.x = Math.round(-screen.zoomX() * (scale - 1));
    this.y = Math.round(-screen.zoomY() * (scale - 1));
    this.x += Math.round(screen.shake());
};
1597785917117.png

I printed out the scale and I think it's actually not intended

1597786101933.png
 

Misappi

Veteran
Veteran
Joined
Apr 16, 2018
Messages
42
Reaction score
26
First Language
Japanese
Primarily Uses
RMMV
I have a theory, you are using a 48*48 grid isn't it?
Does the map length and height is a perfect multiplier or the game resolution?
If not, try to adjust accordingly!
For example a 1280*720 game can have a 80*80 tile size and hit the perfect size if 16 tile large for 9 tiles height (120*120 for 1920*1080 and so on)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
I have a theory, you are using a 48*48 grid isn't it?
Does the map length and height is a perfect multiplier or the game resolution?
If not, try to adjust accordingly!
For example a 1280*720 game can have a 80*80 tile size and hit the perfect size if 16 tile large for 9 tiles height (120*120 for 1920*1080 and so on)
Yes, I'm using 816x624 which is 17 columns and 13 rows.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,846
First Language
English
My bad then, I was wrong!
Did you solved the problem?
Yes. The issue is with the "encounter transition" before a battle begins.
It increases the scale of the BaseSprite, which means the background image shown will also be scaled up.

When I explicitly ignore the scale, it works fine.

Code:
  Spriteset_Base.prototype.updatePosition = function() {
    var screen = $gameScreen;
    // var scale = screen.zoomScale();
    var scale = 1;
    this.scale.x = scale;
    this.scale.y = scale;
    this.x = Math.round(-screen.zoomX() * (scale - 1));
    this.y = Math.round(-screen.zoomY() * (scale - 1));
    this.x += Math.round(screen.shake());
  };
But it might not be a good solution to just reset the screen zoom.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

People3_5 and People3_8 added!

so hopefully tomorrow i get to go home from the hospital i've been here for 5 days already and it's driving me mad. I miss my family like crazy but at least I get to use my own toiletries and my own clothes. My mom is coming to visit soon i can't wait to see her cause i miss her the most. :kaojoy:
Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.

Forum statistics

Threads
105,868
Messages
1,017,090
Members
137,586
Latest member
Usagiis
Top