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: Character Movements (Idle, Walk and Run)
- Original author: fbu
- Original date: August 31, 2019
- Source thread: https://forums.rpgmakerweb.com/threads/character-movements-idle-walk-and-run.112789/
- Source forum path: Game Development Engines > RPG Maker Javascript Plugins > JS Plugin Releases (RMMV)
Summary
Character Movements (Idle, Walk and Run) DESCRIPTION: Allows for player movement to cycle between 3 character sheets: idle, walk and run.
Archived First Post
Character Movements (Idle, Walk and Run)
DESCRIPTION:
Allows for player movement to cycle between 3 character sheets: idle, walk and run.
EXAMPLE:
CODE:
Code:
/*
<Character Movement>
v 0.1 - 31 August 2019
GIT_HUB:
https://github.com/andrefcasimiro/rpg_maker_mv_js/blob/master/Project1/js/plugins/CharacterMovement.js
DESCRIPTION:
Allows for switching between 3 different character sheets: Idle, Walk and Run, according to our movement state.
INSTRUCTIONS:
1. Copy and paste plugin.
2. Choose Idle, Walk and Run character sheets in the plugin's parameters window.
3. Run game.
PARAMS:
@param Actor_{ID}
ID - must be equal to the actor index in the database
@param {Pose}_{ID}
Pose - must be one of the following: 'Idle', 'Walk' or 'Run'
ID - can be anything as long as you don't repeate @param names
*/
/*:
* @plugindesc Allow for player movement to cycle between 3 character sheets: idle, walk and run.
* @author FBU <andrefcasimiro(at)gmail.com>
*
* // ACTOR 1 --------------------------------
* @param Actor_1
*
* @param Idle_Actor1
* @desc "The character set for idle movement"
* @require 1
* @dir img/characters/
* @type file
* @parent Actor_1
*
* @param Walk_Actor1
* @desc "The character set for walk movement"
* @require 1
* @dir img/characters/
* @type file
* @parent Actor_1
*
* @param Run_Actor1
* @desc "The character set for running movement"
* @require 1
* @dir img/characters/
* @type file
* @parent Actor_1
*
*/
(function() {
var Parameters = PluginManager.parameters('CharacterMovement');
var bank = [];
Object.keys(Parameters).forEach((parameterKey, index) => {
var parameterKeyArray = parameterKey.split('_');
var lastIndex = parameterKeyArray && parameterKeyArray[parameterKeyArray.length - 1];
var isID = parameterKeyArray[0] === 'Actor' && !isNaN(lastIndex);
if (isID) {
bank = bank.concat({
actor: lastIndex,
sheet: {},
});
} else {
if (!Parameters[parameterKey]) {
return;
}
var key = parameterKeyArray;
key.length = key.length - 1;
key = key.join('_');
if (bank[bank.length - 1]) {
bank[bank.length - 1].sheet = {
...bank[bank.length - 1].sheet,
[key]: Parameters[parameterKey],
};
}
}
})
var actors = [];
var isDashing, isWalking = false;
var isStopped = true;
var action = 0;
var _cachedAction;
var Scene_Map_Create = Scene_Map.prototype.create;
Scene_Map.prototype.create = function() {
Scene_Map_Create.call(this);
actors = bank.map(entry => $gameActors.actor(entry.actor));
};
var Scene_Map_Update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function() {
Scene_Map_Update.call(this);
managePlayerMovement();
};
var setSheet = function(action) {
actors.forEach(function (actor, index) {
if (!Object.keys(bank[index].sheet).length) {
return;
}
actor.setCharacterImage(bank[index].sheet[action], actor.characterIndex())
});
}
var managePlayerMovement = function() {
isDashing = (!!$gamePlayer.getInputDirection() && $gamePlayer.isDashing()) || !!$gameTemp.isDestinationValid();
isWalking = !!$gamePlayer.getInputDirection() && !isDashing;
isStopped = !isWalking && !isDashing;
if (isStopped) {
action = 0;
} else if (isDashing) {
action = 1;
} else if (isWalking) {
action = 2;
}
if (action !== _cachedAction) {
action === 0
? setSheet('Idle')
: action === 2
? setSheet('Walk')
: setSheet('Run');
$gamePlayer.refresh();
}
_cachedAction = action;
}
})();
[See also on Github]
TERMS:
Can be used freely in commercial and non-commercial projects. No credits required.
Any code suggestions / improvements are welcome.
Enjoy!
Downloads / Referenced Files
Log in to download
Log in, then follow the RPG Maker Developers Group to see these download links.
Log in to downloadLicense / Terms Note
Can be used freely in commercial and non-commercial projects. No credits required. Any code suggestions / improvements are welcome. Enjoy!
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...