jonjons
Member
GM Version: 2.3.1
Target Platform: Windows
Download: https://marketplace.yoyogames.com/assets/9662/skeleton-animation-json
Links: N/A
Summary:
Here is a way to make skeleton animations body Parts and saving it to a JSON file.
I dont know to much about JSON data bases, but i will explain the best way i can.
JSON files usually are big mess...
Sometimes we can see something like var speed = data.player[1].playerType.sp.attributes.xp[71].speed.
Think of it has a shortcut in your hard drive: The Example above would be something like:
c:\data\player\Doom.exe\playerType\sp\attibutes\xp\file71.exe\speed.
another example:
c:\windows\fonts\arial, corbel, new times roman, consoles.
in JSON data{ windows: { fonts: [ arial, corbel, new times roman, consoles ] } }
{ value: } - for names
[ 15, 20, 100 ] - for numbers
An example using GM shortcut
in JSON would be something like:
{ "Data": [ { "GameMakerStudio2": { "files": GM.exe } } ] }
var _a1 = Data.GameMakerStudio2.files.GM.exe
In the example above the speed that it takes to double click on the shortcut, or on the folder containing .exe file, is practical the same.
This way json databases can be very useful, and they can store a lot of info... with a shortcut or a pointer to a value.
Tutorial:
In here if the file mysave33 doesnt exist it creates a new the Json DataBase and naming it mysave33
'It' saves to a json file using this function. The function saves all the body parts to the array with the number of the current [image_index]
To save all the different body parts in all the different image index's number. It cycles through all images very fast saving it with function saveAnim2().
The parts already contain the values corresponding to the current image_index's numbers because they are being moved in the step event.
If you notice the diference between saving a file, and creating a new file if the file doesnt exist
when it creates a new file it saves the same image to all image index's
when it saves the file it only saves to one image index, it has to save manual each image index individually
The mysave33 file is located in Users\userName\local\skeletonAnimtion
This file still contains all the animations when we open or close the project again...
you can use a different file name and save multiple files. ( saveFileName = "mysave33"; )
personally i like to make just one animation, contaning all animation: idle, run, walk, jump, etc..
Target Platform: Windows
Download: https://marketplace.yoyogames.com/assets/9662/skeleton-animation-json
Links: N/A
Summary:
Here is a way to make skeleton animations body Parts and saving it to a JSON file.
I dont know to much about JSON data bases, but i will explain the best way i can.
JSON files usually are big mess...
Sometimes we can see something like var speed = data.player[1].playerType.sp.attributes.xp[71].speed.
Think of it has a shortcut in your hard drive: The Example above would be something like:
c:\data\player\Doom.exe\playerType\sp\attibutes\xp\file71.exe\speed.
another example:
c:\windows\fonts\arial, corbel, new times roman, consoles.
in JSON data{ windows: { fonts: [ arial, corbel, new times roman, consoles ] } }
{ value: } - for names
[ 15, 20, 100 ] - for numbers
An example using GM shortcut
in JSON would be something like:
{ "Data": [ { "GameMakerStudio2": { "files": GM.exe } } ] }
var _a1 = Data.GameMakerStudio2.files.GM.exe
In the example above the speed that it takes to double click on the shortcut, or on the folder containing .exe file, is practical the same.
This way json databases can be very useful, and they can store a lot of info... with a shortcut or a pointer to a value.
Tutorial:
In here if the file mysave33 doesnt exist it creates a new the Json DataBase and naming it mysave33
GML:
if ( file_exists(saveFileName) )
{
var _json = LoadString(saveFileName);
var _root = json_parse(_json);
root = _root;
}
else
{
for (var i = 0; i < sprite_get_number(sprite_index); ++i)
{
root1.Fnum[i] =
{
//headCoord: [ headX, headY],
LhandCoord: { sp: LHandSprite, indx :LHandIndex, Cx: LHandX, Cy: LHandY, Ca: LHandA, Scx: LHandScX, Scy: LHandScY, col: LHandColor, alp: LHandAlpha,},
LarmDownCoord: { sp: LarmDownSprite, indx :LarmDownIndex, Cx: LarmDownX, Cy: LarmDownY, Ca: LarmDownA, Scx: LarmDownScX, Scy: LarmDownScY, col: LarmDownColor, alp: LarmDownAlpha,},
LarmUpCoord: { sp: LarmUpSprite, indx :LarmUpIndex, Cx: LarmUpX, Cy: LarmUpY, Ca: LarmUpA, Scx: LarmUpScX, Scy: LarmUpScY, col: LarmUpColor, alp: LarmUpAlpha,},
torsoCoord: { sp: torsoSprite, indx :torsoIndex, Cx: torsoX, Cy: torsoY, Ca: torsoA, Scx: torsoScX, Scy: torsoScY, col: torsoColor, alp: torsoAlpha,},
waistCoord: { sp: waistSprite, indx :waistIndex, Cx: waistX, Cy: waistY, Ca: waistA, Scx: waistScX, Scy: waistScY, col: waistColor, alp: waistAlpha,},
LfootCoord: { sp: LfootSprite, indx :LfootIndex, Cx: LfootX, Cy: LfootY, Ca: LfootA, Scx: LfootScX, Scy: LfootScY, col: LfootColor, alp: LfootAlpha,},
LlegDownCoord: { sp: LlegDownSprite, indx :LlegDownIndex, Cx: LlegDownX, Cy: LlegDownY, Ca: LlegDownA, Scx: LlegDownScX, Scy: LlegDownScY, col: LlegDownColor, alp: LlegDownAlpha,},
LlegUpCoord: { sp: LlegUpSprite, indx :LlegUpIndex, Cx: LlegUpX, Cy: LlegUpY, Ca: LlegUpA, Scx: LlegUpScX, Scy: LlegUpScY, col: LlegUpColor, alp: LlegUpAlpha,},
headCoord: { sp: headSprite, indx :headIndex, Cx: headX, Cy: headY, Ca: headA, Scx: headScX, Scy: headScY, col: headColor, alp: headAlpha,},
RfootCoord: { sp: RfootSprite, indx :RfootIndex, Cx: RfootX, Cy: RfootY, Ca: RfootA, Scx: RfootScX, Scy: RfootScY, col: RfootColor, alp: RfootAlpha,},
RlegDowCoord: { sp: RlegDownSprite, indx :RlegDownIndex, Cx: RlegDownX, Cy: RlegDownY, Ca: RlegDownA, Scx: RlegDownScX, Scy: RlegDownScY, col: RlegDownColor, alp: RlegDownAlpha,},
RlegUpCoord: { sp: RlegUpSprite, indx :RlegUpIndex, Cx: RlegUpX, Cy: RlegUpY, Ca: RlegUpA, Scx: RlegUpScX, Scy: RlegUpScY, col: RlegUpColor, alp: RlegUpAlpha,},
RHandCoord: { sp: RHandSprite, indx :RHandIndex, Cx: RHandX, Cy: RHandY, Ca: RHandA, Scx: RHandScX, Scy: RHandScY, col: RHandColor, alp: RHandAlpha,},
RarmDownCoord: { sp: RarmDownSprite, indx :RarmDownIndex, Cx: RarmDownX, Cy: RarmDownY, Ca: RarmDownA, Scx: RarmDownScX, Scy: RarmDownScY, col: RarmDownColor, alp: RarmDownAlpha,},
RarmUpCoord: { sp: RarmUpSprite, indx :RarmUpIndex, Cx: RarmUpX, Cy: RarmUpY, Ca: RarmUpA, Scx: RarmUpScX, Scy: RarmUpScY, col: RarmUpColor, alp: RarmUpAlpha,},
//LarmUpCoord: { Cx: LarmUpX, Cy :LarmUpY, },
//RarmUpCoord: { Cx: RarmUpX, Cy :RarmUpY, },
}
}
var _json = json_stringify(root1);
SaveString(_json, saveFileName);
var _root2= json_parse(_json);
root = _root2;
}
'It' saves to a json file using this function. The function saves all the body parts to the array with the number of the current [image_index]
GML:
saveFileName = "mysave33";
//-----------------------//----//----------//-----------
root = 0;
root1 = {
Fnum : array_create(sprite_get_number(sprite_index))
}
saveAnim2 = function () {
root1.Fnum[image_index] =
{
//headCoord: [ headX, headY],
LhandCoord: { sp: LHandSprite, indx :LHandIndex, Cx: LHandX, Cy: LHandY, Ca: LHandA, Scx: LHandScX, Scy: LHandScY, col: LHandColor, alp: LHandAlpha,},
LarmDownCoord: { sp: LarmDownSprite, indx :LarmDownIndex, Cx: LarmDownX, Cy: LarmDownY, Ca: LarmDownA, Scx: LarmDownScX, Scy: LarmDownScY, col: LarmDownColor, alp: LarmDownAlpha,},
LarmUpCoord: { sp: LarmUpSprite, indx :LarmUpIndex, Cx: LarmUpX, Cy: LarmUpY, Ca: LarmUpA, Scx: LarmUpScX, Scy: LarmUpScY, col: LarmUpColor, alp: LarmUpAlpha,},
torsoCoord: { sp: torsoSprite, indx :torsoIndex, Cx: torsoX, Cy: torsoY, Ca: torsoA, Scx: torsoScX, Scy: torsoScY, col: torsoColor, alp: torsoAlpha,},
waistCoord: { sp: waistSprite, indx :waistIndex, Cx: waistX, Cy: waistY, Ca: waistA, Scx: waistScX, Scy: waistScY, col: waistColor, alp: waistAlpha,},
LfootCoord: { sp: LfootSprite, indx :LfootIndex, Cx: LfootX, Cy: LfootY, Ca: LfootA, Scx: LfootScX, Scy: LfootScY, col: LfootColor, alp: LfootAlpha,},
LlegDownCoord: { sp: LlegDownSprite, indx :LlegDownIndex, Cx: LlegDownX, Cy: LlegDownY, Ca: LlegDownA, Scx: LlegDownScX, Scy: LlegDownScY, col: LlegDownColor, alp: LlegDownAlpha,},
LlegUpCoord: { sp: LlegUpSprite, indx :LlegUpIndex, Cx: LlegUpX, Cy: LlegUpY, Ca: LlegUpA, Scx: LlegUpScX, Scy: LlegUpScY, col: LlegUpColor, alp: LlegUpAlpha,},
headCoord: { sp: headSprite, indx :headIndex, Cx: headX, Cy: headY, Ca: headA, Scx: headScX, Scy: headScY, col: headColor, alp: headAlpha,},
RfootCoord: { sp: RfootSprite, indx :RfootIndex, Cx: RfootX, Cy: RfootY, Ca: RfootA, Scx: RfootScX, Scy: RfootScY, col: RfootColor, alp: RfootAlpha,},
RlegDowCoord: { sp: RlegDownSprite, indx :RlegDownIndex, Cx: RlegDownX, Cy: RlegDownY, Ca: RlegDownA, Scx: RlegDownScX, Scy: RlegDownScY, col: RlegDownColor, alp: RlegDownAlpha,},
RlegUpCoord: { sp: RlegUpSprite, indx :RlegUpIndex, Cx: RlegUpX, Cy: RlegUpY, Ca: RlegUpA, Scx: RlegUpScX, Scy: RlegUpScY, col: RlegUpColor, alp: RlegUpAlpha,},
RHandCoord: { sp: RHandSprite, indx :RHandIndex, Cx: RHandX, Cy: RHandY, Ca: RHandA, Scx: RHandScX, Scy: RHandScY, col: RHandColor, alp: RHandAlpha,},
RarmDownCoord: { sp: RarmDownSprite, indx :RarmDownIndex, Cx: RarmDownX, Cy: RarmDownY, Ca: RarmDownA, Scx: RarmDownScX, Scy: RarmDownScY, col: RarmDownColor, alp: RarmDownAlpha,},
RarmUpCoord: { sp: RarmUpSprite, indx :RarmUpIndex, Cx: RarmUpX, Cy: RarmUpY, Ca: RarmUpA, Scx: RarmUpScX, Scy: RarmUpScY, col: RarmUpColor, alp: RarmUpAlpha,},
}
var _json = json_stringify(root1);
SaveString(_json, saveFileName);
}
To save all the different body parts in all the different image index's number. It cycles through all images very fast saving it with function saveAnim2().
GML:
else if (keyboard_check_pressed(vk_f1))
{
isSave = ! isSave;
savINFO = 1;
image_index = 0;
imgSpeed = 0;
}
.........
..............
......................
if ( isSave == true )
{
imgSpeed = 25;
saveAnim2();
if (image_index >= image_number - 0.5)
{
imgSpeed = 0;
isSave = false;
}
}
The parts already contain the values corresponding to the current image_index's numbers because they are being moved in the step event.
GML:
case 1:
info_part = "HEAD";
info_coordX = headX;
info_coordY = headY;
info_coordA = headA;
info_coordSx = headScX;
info_coordSy = headScY;
root.Fnum[image_index].headCoord.Cx += move_part(0.5, "A", "D");
root.Fnum[image_index].headCoord.Cy += move_part(0.5, "W", "S");
root.Fnum[image_index].headCoord.Ca += move_part(1.5, "E", "Q");
root.Fnum[image_index].headCoord.Scx += move_part(0.05, "V", "Z");
root.Fnum[image_index].headCoord.Scy += move_part(0.05, "C", "X");
if ( root.Fnum[image_index].headCoord.Ca > 355 || root.Fnum[image_index].headCoord.Ca < -360 || keyboard_check_pressed(ord("R")))
{
root.Fnum[image_index].headCoord.Ca = 0;
}
if ( keyboard_check_pressed(ord("F")))
{
root.Fnum[image_index].headCoord.Scx = 1;
root.Fnum[image_index].headCoord.Scy = 1;
}
break;
If you notice the diference between saving a file, and creating a new file if the file doesnt exist
when it creates a new file it saves the same image to all image index's
when it saves the file it only saves to one image index, it has to save manual each image index individually
GML:
//------------saving-the-file---------//----//----------//-----------
root = 0;
root1 = {
Fnum : array_create(sprite_get_number(sprite_index))
}
saveAnim2 = function () {
root1.Fnum[image_index] =
{
//headCoord: [ headX, headY],
LhandCoord: { sp: LHandSprite, indx :LHandIndex, Cx: LHandX, Cy: LHandY, Ca: LHandA, Scx: LHandScX, Scy: LHandScY, col: LHandColor, alp: LHandAlpha,},
LarmDownCoord: { sp: LarmDownSprite, indx :LarmDownIndex, Cx: LarmDownX, Cy: LarmDownY, Ca: LarmDownA, Scx: LarmDownScX, Scy: LarmDownScY, col: LarmDownColor, alp: LarmDownAlpha,},
LarmUpCoord: { sp: LarmUpSprite, indx :LarmUpIndex, Cx: LarmUpX, Cy: LarmUpY, Ca: LarmUpA, Scx: LarmUpScX, Scy: LarmUpScY, col: LarmUpColor, alp: LarmUpAlpha,},
torsoCoord: { sp: torsoSprite, indx :torsoIndex, Cx: torsoX, Cy: torsoY, Ca: torsoA, Scx: torsoScX, Scy: torsoScY, col: torsoColor, alp: torsoAlpha,},
waistCoord: { sp: waistSprite, indx :waistIndex, Cx: waistX, Cy: waistY, Ca: waistA, Scx: waistScX, Scy: waistScY, col: waistColor, alp: waistAlpha,},
LfootCoord: { sp: LfootSprite, indx :LfootIndex, Cx: LfootX, Cy: LfootY, Ca: LfootA, Scx: LfootScX, Scy: LfootScY, col: LfootColor, alp: LfootAlpha,},
LlegDownCoord: { sp: LlegDownSprite, indx :LlegDownIndex, Cx: LlegDownX, Cy: LlegDownY, Ca: LlegDownA, Scx: LlegDownScX, Scy: LlegDownScY, col: LlegDownColor, alp: LlegDownAlpha,},
LlegUpCoord: { sp: LlegUpSprite, indx :LlegUpIndex, Cx: LlegUpX, Cy: LlegUpY, Ca: LlegUpA, Scx: LlegUpScX, Scy: LlegUpScY, col: LlegUpColor, alp: LlegUpAlpha,},
headCoord: { sp: headSprite, indx :headIndex, Cx: headX, Cy: headY, Ca: headA, Scx: headScX, Scy: headScY, col: headColor, alp: headAlpha,},
RfootCoord: { sp: RfootSprite, indx :RfootIndex, Cx: RfootX, Cy: RfootY, Ca: RfootA, Scx: RfootScX, Scy: RfootScY, col: RfootColor, alp: RfootAlpha,},
RlegDowCoord: { sp: RlegDownSprite, indx :RlegDownIndex, Cx: RlegDownX, Cy: RlegDownY, Ca: RlegDownA, Scx: RlegDownScX, Scy: RlegDownScY, col: RlegDownColor, alp: RlegDownAlpha,},
RlegUpCoord: { sp: RlegUpSprite, indx :RlegUpIndex, Cx: RlegUpX, Cy: RlegUpY, Ca: RlegUpA, Scx: RlegUpScX, Scy: RlegUpScY, col: RlegUpColor, alp: RlegUpAlpha,},
RHandCoord: { sp: RHandSprite, indx :RHandIndex, Cx: RHandX, Cy: RHandY, Ca: RHandA, Scx: RHandScX, Scy: RHandScY, col: RHandColor, alp: RHandAlpha,},
RarmDownCoord: { sp: RarmDownSprite, indx :RarmDownIndex, Cx: RarmDownX, Cy: RarmDownY, Ca: RarmDownA, Scx: RarmDownScX, Scy: RarmDownScY, col: RarmDownColor, alp: RarmDownAlpha,},
RarmUpCoord: { sp: RarmUpSprite, indx :RarmUpIndex, Cx: RarmUpX, Cy: RarmUpY, Ca: RarmUpA, Scx: RarmUpScX, Scy: RarmUpScY, col: RarmUpColor, alp: RarmUpAlpha,},
}
var _json = json_stringify(root1);
SaveString(_json, saveFileName);
}
//------------creating-a-new-file---//---------------//-------------------
if ( file_exists(saveFileName) )
{
var _json = LoadString(saveFileName);
var _root = json_parse(_json);
root = _root;
}
else
{
for (var i = 0; i < sprite_get_number(sprite_index); ++i)
{
root1.Fnum[I] =
{
//headCoord: [ headX, headY],
LhandCoord: { sp: LHandSprite, indx :LHandIndex, Cx: LHandX, Cy: LHandY, Ca: LHandA, Scx: LHandScX, Scy: LHandScY, col: LHandColor, alp: LHandAlpha,},
LarmDownCoord: { sp: LarmDownSprite, indx :LarmDownIndex, Cx: LarmDownX, Cy: LarmDownY, Ca: LarmDownA, Scx: LarmDownScX, Scy: LarmDownScY, col: LarmDownColor, alp: LarmDownAlpha,},
LarmUpCoord: { sp: LarmUpSprite, indx :LarmUpIndex, Cx: LarmUpX, Cy: LarmUpY, Ca: LarmUpA, Scx: LarmUpScX, Scy: LarmUpScY, col: LarmUpColor, alp: LarmUpAlpha,},
torsoCoord: { sp: torsoSprite, indx :torsoIndex, Cx: torsoX, Cy: torsoY, Ca: torsoA, Scx: torsoScX, Scy: torsoScY, col: torsoColor, alp: torsoAlpha,},
waistCoord: { sp: waistSprite, indx :waistIndex, Cx: waistX, Cy: waistY, Ca: waistA, Scx: waistScX, Scy: waistScY, col: waistColor, alp: waistAlpha,},
LfootCoord: { sp: LfootSprite, indx :LfootIndex, Cx: LfootX, Cy: LfootY, Ca: LfootA, Scx: LfootScX, Scy: LfootScY, col: LfootColor, alp: LfootAlpha,},
LlegDownCoord: { sp: LlegDownSprite, indx :LlegDownIndex, Cx: LlegDownX, Cy: LlegDownY, Ca: LlegDownA, Scx: LlegDownScX, Scy: LlegDownScY, col: LlegDownColor, alp: LlegDownAlpha,},
LlegUpCoord: { sp: LlegUpSprite, indx :LlegUpIndex, Cx: LlegUpX, Cy: LlegUpY, Ca: LlegUpA, Scx: LlegUpScX, Scy: LlegUpScY, col: LlegUpColor, alp: LlegUpAlpha,},
headCoord: { sp: headSprite, indx :headIndex, Cx: headX, Cy: headY, Ca: headA, Scx: headScX, Scy: headScY, col: headColor, alp: headAlpha,},
RfootCoord: { sp: RfootSprite, indx :RfootIndex, Cx: RfootX, Cy: RfootY, Ca: RfootA, Scx: RfootScX, Scy: RfootScY, col: RfootColor, alp: RfootAlpha,},
RlegDowCoord: { sp: RlegDownSprite, indx :RlegDownIndex, Cx: RlegDownX, Cy: RlegDownY, Ca: RlegDownA, Scx: RlegDownScX, Scy: RlegDownScY, col: RlegDownColor, alp: RlegDownAlpha,},
RlegUpCoord: { sp: RlegUpSprite, indx :RlegUpIndex, Cx: RlegUpX, Cy: RlegUpY, Ca: RlegUpA, Scx: RlegUpScX, Scy: RlegUpScY, col: RlegUpColor, alp: RlegUpAlpha,},
RHandCoord: { sp: RHandSprite, indx :RHandIndex, Cx: RHandX, Cy: RHandY, Ca: RHandA, Scx: RHandScX, Scy: RHandScY, col: RHandColor, alp: RHandAlpha,},
RarmDownCoord: { sp: RarmDownSprite, indx :RarmDownIndex, Cx: RarmDownX, Cy: RarmDownY, Ca: RarmDownA, Scx: RarmDownScX, Scy: RarmDownScY, col: RarmDownColor, alp: RarmDownAlpha,},
RarmUpCoord: { sp: RarmUpSprite, indx :RarmUpIndex, Cx: RarmUpX, Cy: RarmUpY, Ca: RarmUpA, Scx: RarmUpScX, Scy: RarmUpScY, col: RarmUpColor, alp: RarmUpAlpha,},
//LarmUpCoord: { Cx: LarmUpX, Cy :LarmUpY, },
//RarmUpCoord: { Cx: RarmUpX, Cy :RarmUpY, },
}
}
var _json = json_stringify(root1);
SaveString(_json, saveFileName);
var _root2= json_parse(_json);
root = _root2;
}
The mysave33 file is located in Users\userName\local\skeletonAnimtion
This file still contains all the animations when we open or close the project again...
you can use a different file name and save multiple files. ( saveFileName = "mysave33"; )
personally i like to make just one animation, contaning all animation: idle, run, walk, jump, etc..
Last edited: