Preserved forum archive. This topic stores the original first post and locally mirrored RPG Maker Web attachments when available. It is posted by the BMMPlay archive account, not by the original creator.
Original Source
- Original title: camera shift left right
- Original author: pasunna
- Original date: February 27, 2020
- Source thread: https://forums.rpgmakerweb.com/threads/camera-shift-left-right.118635/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > Learning Javascript
Summary
Hi I'm working on side scrolling game and the Rpg Maker camera always lock to the center I want make the camera adjust by player facing
Archived First Post
Hi
I'm working on side scrolling game
and the Rpg Maker camera always lock to the center
I want make the camera adjust by player facing
right is -3 tile etc
and go make a shot in this
but turn out it work only in negative way
like when face right the camera will shift to the left
Protected download
it's opposite of what I want
(the guy in picture suppose to stand on the left instead)
when I try to change the +/- sequence
another outcome just doesn't change anything and lock the character to center like default
So...
I try around on those
but can't find a good outcome too
thank you
I'm working on side scrolling game
and the Rpg Maker camera always lock to the center
I want make the camera adjust by player facing
right is -3 tile etc
and go make a shot in this
Code:
Game_Player.prototype.centerX = function() {
var x = (Graphics.width / $gameMap.tileWidth() - 1) / 2.0;
var d = this.direction();
var i = 3;
if(d === 4){
x += i;
}
if(d === 6){
x -= i;
}
return x;
};
but turn out it work only in negative way
like when face right the camera will shift to the left
Protected download
it's opposite of what I want
(the guy in picture suppose to stand on the left instead)
when I try to change the +/- sequence
another outcome just doesn't change anything and lock the character to center like default
So...
I try around on those
Code:
Game_Player.prototype.centerY = function() {
var y =(Graphics.height / $gameMap.tileHeight() - 1) / 2.0;
y += 1;
return y;
return (Graphics.height / $gameMap.tileHeight() - 1 + 3) / 2.0;
};
Game_Map.prototype.setDisplayPos = function(x, y) {
//y += 3;
if (this.isLoopHorizontal()) {
this._displayX = x.mod(this.width());
this._parallaxX = x;
} else {
var endX = this.width() - this.screenTileX();
this._displayX = endX < 0 ? endX / 2 : x.clamp(0, endX);
this._parallaxX = this._displayX;
}
if (this.isLoopVertical()) {
this._displayY = y.mod(this.height());
this._parallaxY = y;
} else {
var endY = this.height() - this.screenTileY();
this._displayY = endY < 0 ? endY / 2 : y.clamp(0, endY);
//this._displayY += 6;
this._parallaxY = this._displayY;
}
};
Game_Player.prototype.updateScroll = function(lastScrolledX, lastScrolledY) {
var x1 = lastScrolledX;
var y1 = lastScrolledY;
var x2 = this.scrolledX();
var y2 = this.scrolledY();
if (y2 > y1 && y2 > this.centerY()) {
$gameMap.scrollDown(y2 - y1);
}
if (x2 < x1 && x2 < this.centerX()) {
$gameMap.scrollLeft(x1 - x2);
}
if (x2 > x1 && x2 > this.centerX()) {
$gameMap.scrollRight(x2 - x1);
}
if (y2 < y1 && y2 < this.centerY()) {
$gameMap.scrollUp(y1 - y2);
}
};
Game_Map.prototype.scrollDown = function(distance) {
if (this.isLoopVertical()) {
this._displayY += distance;
this._displayY %= $dataMap.height;
if (this._parallaxLoopY) {
this._parallaxY += distance;
}
} else if (this.height() >= this.screenTileY()) {
var lastY = this._displayY;
this._displayY = Math.min(this._displayY + distance,
this.height() - this.screenTileY());
this._parallaxY += this._displayY - lastY;
}
};
Game_Map.prototype.scrollLeft = function(distance) {
if (this.isLoopHorizontal()) {
this._displayX += $dataMap.width - distance;
this._displayX %= $dataMap.width;
if (this._parallaxLoopX) {
this._parallaxX -= distance;
}
} else if (this.width() >= this.screenTileX()) {
var lastX = this._displayX;
this._displayX = Math.max(this._displayX - distance, 0);
this._parallaxX += this._displayX - lastX;
}
};
Game_Map.prototype.scrollRight = function(distance) {
if (this.isLoopHorizontal()) {
this._displayX += distance;
this._displayX %= $dataMap.width;
if (this._parallaxLoopX) {
this._parallaxX += distance;
}
} else if (this.width() >= this.screenTileX()) {
var lastX = this._displayX;
this._displayX = Math.min(this._displayX + distance,
this.width() - this.screenTileX());
this._parallaxX += this._displayX - lastX;
}
};
Game_Map.prototype.scrollUp = function(distance) {
if (this.isLoopVertical()) {
this._displayY += $dataMap.height - distance;
this._displayY %= $dataMap.height;
if (this._parallaxLoopY) {
this._parallaxY -= distance;
}
} else if (this.height() >= this.screenTileY()) {
var lastY = this._displayY;
this._displayY = Math.max(this._displayY - distance, 0);
this._parallaxY += this._displayY - lastY;
}
};
thank you
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadReferenced Images / Attachments
Creator Claims / Removal
If you are the original creator and want this listing reassigned, edited, or removed, join BMMPlay and contact the moderators with proof that matches the original RPG Maker Web profile, linked GitHub, itch.io page, or another public creator identity.
Replies (0)
No replies yet.
0
replies
1
view
Topic Summary
Loading summary...
