flip character sprite in set frame

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
170
Reaction score
27
First Language
thai
Primarily Uses
RMMV
Hi
I use only left rigth sprite and in fact left and rigth are just flip version
so I want to change set frame function to draw only one line of sprite and just flip it by code
Code:
Sprite_Character.prototype.updateCharacterFrame = function() {
    var pw = this.patternWidth();
    var ph = this.patternHeight();
    var sx = (this.characterBlockX() + this.characterPatternX()) * pw;
    var sy = (this.characterBlockY() + this.characterPatternY()) * ph;
    this.updateHalfBodySprites();
    if (this._bushDepth > 0) {
        var d = this._bushDepth;
        this._upperBody.setFrame(sx, sy, pw, ph - d);
        this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
        this.setFrame(sx, sy, 0, ph);
    } else {
        this.setFrame(sx, sy, pw, ph);
    }
};
so I aim to this code and edit it to this

Code:
Sprite_Character.prototype.updateCharacterFrame = function() {
    var pw = this.patternWidth();
    var ph = this.patternHeight();
    var sx = (this.characterBlockX() + this.characterPatternX()) * pw;
    var sy = (this.characterBlockY() + this.characterPatternY()) * ph;
    
    if (this._isBigCharacter) {
        sy = 0;// < use only one/first line sprite frame
        ph = this.height;//< hieght of image
        var even = this._character;
        var d = even.direction();// - 2) / 2;
        var flip = 0;
        if(d === 4){
            //testtext(d)// < check if direction = right
            this.scale.x *= -1; //< flip the sprite
        }
        this.setFrame(sx, sy, pw, ph)
        return
    }


    this.updateHalfBodySprites();
    if (this._bushDepth > 0) {
        var d = this._bushDepth;
        this._upperBody.setFrame(sx, sy, pw, ph - d);
        this._lowerBody.setFrame(sx, sy + ph - d, pw, d);
        this.setFrame(sx, sy, 0, ph);
    } else {
        this.setFrame(sx, sy, pw, ph);
    }

};
The only one line use image had no problem
but the flipping sprite not work
I try mess up with many other area but no solution
any Idea?
thank you
 

Waterguy

Veteran
Veteran
Joined
Jun 6, 2014
Messages
1,399
Reaction score
316
First Language
Portuguese
Primarily Uses
RMMV
you could use the original direction but set its x scale to be negative?
 

pasunna

Veteran
Veteran
Joined
Feb 3, 2019
Messages
170
Reaction score
27
First Language
thai
Primarily Uses
RMMV
you could use the original direction but set its x scale to be negative?
yes... turn out it conflict with other plugin I use that override it
so it simple as that
thank you
 

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

Latest Threads

Latest Posts

Latest Profile Posts

i watched the sonic movie it was pretty good i hope they make a sequel
tomorrow I'ma go on a cruise for the first time ever... lets hope I'll survive the experience!
Omg! 8 years in this forum :o
Ksi
Streaming the last of the RMN Valentiny event games so feel free to drop on by and watch me cry (whether that's from laughter, rage or sheer pain, who knows?)
Today I went to sleep without setting an alarm, so I could sleep more than 2 hours. I woke up after 2 hours.

Forum statistics

Threads
94,309
Messages
919,827
Members
124,060
Latest member
jloppnow
Top