This module will eventually replace the animation sheet of your hero and these 3 followers.
My project has only 2 follower, so I'm not pushing my test further with the plugin.
The player and fellower need to start with motionContext prepare in advance.
for the time being.
In your pluginManager
** plug1.4

Insert in the list the names of the Object you want to assign to your character.
1: player, 2,3,4 fellower
Now, as for the Picture module, we duplicate a new Object.
The syntax remains the same, but this time we will add some additional information and property to run our character.
Our character in this demo is the one of my project.
My project is paper-type as in Mario Paper.
So only 2 possible direction, however we wish that when the character goes up or down, it plays an animation keeping the last direction valid.
We will see how to integrate the 8 direction depending on your project type.
** js1.3

Here we have our valid animation which displays our character on the right.
We add the dir: 6 property which is required for the character module.
In rmmv the directions simply refer to your numPad.
** mod2.1

4: left, 6: right, 8: up, 2: down.
We must therefore assign the directions to our animation for our character.
For our example, we would have 4 direction, however it would be quite easy to add diagonal as well.
7,9,1,3
PHP:
myPlayer1:{
json:['testSmallPlayerAni/h1test'],
motionList:{
idl1Ri:{ref:'H1IDLE1_',framesRange:[0,19],speed:0.3,anchor:[0.5,1],loop:true,dir:6},
idl1Le:{ref:'H1IDLE1_',framesRange:[0,19],scale:[-1,1],speed:0.3,anchor:[0.5,1],loop:true,dir:4},
},
},
Our character has no animation texture on the left, we are all able to add a Scale property: [sX, sY] in order to invert these texture.
For the texture we simply assign it the same source of our file JSON.
When our character is left (4) and without movement, it will display the same texture as for idleRi, but reverse.
Be careful however if you want to use repositioning of the pivot, it will be necessary to assign the same for each animations.
This is a fast but restrictive method if you want to configure different pivots.
Now for the top (8) and bottom (2) directions, our character also has no texture when it does not move.
In the Object ref: it is quite possible to add a reference to another motion and this is conditional.
PHP:
myPlayer1:{
json:['testSmallPlayerAni/h1test'],
motionList:{
idl1Ri:{ref:'H1IDLE1_',framesRange:[0,19],speed:0.3,anchor:[0.5,1],loop:true,dir:6},
idl1Le:{ref:'H1IDLE1_',framesRange:[0,19],scale:[-1,1],speed:0.3,anchor:[0.5,1],loop:true,dir:4},
idlUp:{ref:{4:'idl1Le',6:'idl1Ri'},dir:8},
idlDw:{ref:{4:'idl1Le',6:'idl1Ri'},dir:2},
},
},
It is enough to pass an Object that points towards the motion wish.
But in our special case our character is a sheet of paper that can only look left or right.
So when the character will be motionless and will be in direction 8, it is instead passed an Object that contains the pointer.
the plugin will automatically evaluate the last valid direction.
A valid direction is automate calculate according to the type of animation inject into the plugin.
ex: here the plugin will understand that 8 and 2 can not be a valid direction, however 6 and 4 yes.
So when we press on 4,8,6,6,2, the last valid direction will be 6.
6,6,4,8,8,2, the last valid direction will be 4.
So if we press 8 and the last valid direction was 4, we want to play the idle motion if the character does not move.
Now add the remaining motions
PHP:
myPlayer1:{
json:['testSmallPlayerAni/h1test'],
motionList:{
idl1Ri:{ref:'H1IDLE1_',framesRange:[0,19],speed:0.3,anchor:[0.5,1],loop:true,dir:6},
idl1Le:{ref:'H1IDLE1_',framesRange:[0,19],scale:[-1,1],speed:0.3,anchor:[0.5,1],loop:true,dir:4},
idlUp:{ref:{4:'idl1Le',6:'idl1Ri'},dir:8},
idlDw:{ref:{4:'idl1Le',6:'idl1Ri'},dir:2},
moveR1:{ref:'H1moveDG1_',framesRange:[0,49],anchor:[0.5,0.93]},
moveL1:{ref:'H1moveDG1_',framesRange:[0,49],scale:[-1,1],anchor:[0.5,0.93]},
moveUpR1:{ref:'H1moveUP_',framesRange:[0,49],anchor:[0.5,1]},
moveDwL1:{ref:'H1moveDW_',framesRange:[0,49],anchor:[0.5,1]},
moveUpG1:{ref:'H1moveUP_',framesRange:[0,49],scale:[-1,1],anchor:[0.5,1]},
moveDwG1:{ref:'H1moveDW_',framesRange:[0,49],scale:[-1,1],anchor:[0.5,1]},
},
},
Unlike our idle animation, our character will have special animations here when moving up or down and this depending on the directional contexts that will be added in motionContext.
Also reverse our textures to the left direction, because the character has only textures to the right.
Now add the motion contexts.
For Object assign to the Player module and follower, it is compulsory to add the motion contexts associated with the direction key as soon as the project starts.
this motion predefined contexts is addMotionContext_onMoved.
it is possible to modify it or to add it in playground, but it is obligatory to add 1 for each direction of the character
PHP:
myPlayer1:{
json:['testSmallPlayerAni/h1test'],
motionList:{
idl1Ri:{ref:'H1IDLE1_',framesRange:[0,19],speed:0.3,anchor:[0.5,1],loop:true,dir:6},
idl1Le:{ref:'H1IDLE1_',framesRange:[0,19],scale:[-1,1],speed:0.3,anchor:[0.5,1],loop:true,dir:4},
idlUp:{ref:{4:'idl1Le',6:'idl1Ri'},dir:8},
idlDw:{ref:{4:'idl1Le',6:'idl1Ri'},dir:2},
moveR1:{ref:'H1moveDG1_',framesRange:[0,49],anchor:[0.5,0.93]},
moveL1:{ref:'H1moveDG1_',framesRange:[0,49],scale:[-1,1],anchor:[0.5,0.93]},
moveUpR1:{ref:'H1moveUP_',framesRange:[0,49],anchor:[0.5,1]},
moveDwR1:{ref:'H1moveDW_',framesRange:[0,49],anchor:[0.5,1]},
moveUpL1:{ref:'H1moveUP_',framesRange:[0,49],scale:[-1,1],anchor:[0.5,1]},
moveDwL1:{ref:'H1moveDW_',framesRange:[0,49],scale:[-1,1],anchor:[0.5,1]},
},
motionContexts:[
['addMotionContext_onMoved','idl1Le',{ 2:' moveDwL1', 4:' moveL1', 8:' moveUpL1', },100],
['addMotionContext_onMoved','idl1Ri',{ 2:' moveDwR1', 6:'moveR1', 8:' moveUpR1', },100],
],
},
I will not go into detail, but the addMotionContext_onMoved is the only special context that is not saved in the update, for logical reason.
it will be called on demand only when a key is pressed.
All other motionContext are saved in onFrames update.
Here, at the moment when the character is moved, he will send a context of devaluation according to the animation that is in the rendering court.
When pressed a direction key, the character changes direction Pui evaluates onMoved.
So if we look at left (2), the character changes direction and becomes idle, then we ask for an evaluation of the road.
If possible we evaluate onMoved, which returns motion animation according to the key assign.
You will have understood that I thought the system to add an animation when the character changes direction.
We can finish by duplicating the integrals of this Object by taking care of changing the name by the one attribute to the follower.
And we logically change the reference of the motions and the parameters that we want to attribute to this follower.