Hello, recently I've been wandering around searching for a solution on how to implement the wonders of Spine into RMMV. I'll try to post it all here so that nothing is missing.
I'm 100% sure there's some useless code in there, but it somehow works. What was done was downloading pixi-spine.js from github, adding also the spine runtime folders and adding a line in the index so that pixi-spine script is recognized (half a day went into this). then I went on Pixi.js website and copied the example code, I added the spine-data folder to my project and wow it works. (in order to check fastly I used the moving function so that I just had to click and see.
Problem is: this guy is in a canvas that is below everything. How can I fix it?
I'm desperate lol, any help is appreciated.
I'm 100% sure there's some useless code in there, but it somehow works. What was done was downloading pixi-spine.js from github, adding also the spine runtime folders and adding a line in the index so that pixi-spine script is recognized (half a day went into this). then I went on Pixi.js website and copied the example code, I added the spine-data folder to my project and wow it works. (in order to check fastly I used the moving function so that I just had to click and see.
Problem is: this guy is in a canvas that is below everything. How can I fix it?
//=============================================================================
// Spine.js
//=============================================================================
/*:
* @plugindesc A plug in that holds Spine animations
* @author Erikari
*
* @help This plugin does not provide plugin commands.
*/
(function() {
Game_Player.prototype.executeMove = function(direction) {
var renderer = PIXI.autoDetectRenderer(900, 600);
document.body.appendChild(renderer.view);
// create the root of the scene graph
var stage = new PIXI.Container();
UpperCanvas.appendChildAt(this.stage,6)
// load spine data
PIXI.loader
//spineCharacter
.add('spineboy', 'spine-data/spineboy.json')
.load(onAssetsLoaded);
stage.interactive = true;
function onAssetsLoaded(loader, res) {
console.log(res);
// create a spine boy
var spineBoy = new PIXI.spine.Spine(res.spineboy.spineData);
// set the position
spineBoy.position.x = renderer.width / 2;
spineBoy.position.y = renderer.height;
spineBoy.scale.set(1.5);
// set up the mixes!
spineBoy.stateData.setMixByName('walk', 'jump', 0.2);
spineBoy.stateData.setMixByName('jump', 'walk', 0.4);
// play animation
spineBoy.state.setAnimationByName(0, 'walk', true);
stage.addChild(spineBoy);
stage.on('click', function () {
spineBoy.state.setAnimationByName(0, 'jump', false);
spineBoy.state.addAnimationByName(0, 'walk', true, 0);
});
}
requestAnimationFrame(animate);
function animate() {
requestAnimationFrame(animate);
renderer.render(stage);
}
};
})();
I'm pretty sure I could have avoided posting all this code but if only the other Japanese super guy who got it to work had done the same, (and unfortunately I don't know Japanese) I wouldn't be here, so instead, I'm sharing.// Spine.js
//=============================================================================
/*:
* @plugindesc A plug in that holds Spine animations
* @author Erikari
*
* @help This plugin does not provide plugin commands.
*/
(function() {
Game_Player.prototype.executeMove = function(direction) {
var renderer = PIXI.autoDetectRenderer(900, 600);
document.body.appendChild(renderer.view);
// create the root of the scene graph
var stage = new PIXI.Container();
UpperCanvas.appendChildAt(this.stage,6)
// load spine data
PIXI.loader
//spineCharacter
.add('spineboy', 'spine-data/spineboy.json')
.load(onAssetsLoaded);
stage.interactive = true;
function onAssetsLoaded(loader, res) {
console.log(res);
// create a spine boy
var spineBoy = new PIXI.spine.Spine(res.spineboy.spineData);
// set the position
spineBoy.position.x = renderer.width / 2;
spineBoy.position.y = renderer.height;
spineBoy.scale.set(1.5);
// set up the mixes!
spineBoy.stateData.setMixByName('walk', 'jump', 0.2);
spineBoy.stateData.setMixByName('jump', 'walk', 0.4);
// play animation
spineBoy.state.setAnimationByName(0, 'walk', true);
stage.addChild(spineBoy);
stage.on('click', function () {
spineBoy.state.setAnimationByName(0, 'jump', false);
spineBoy.state.addAnimationByName(0, 'walk', true, 0);
});
}
requestAnimationFrame(animate);
function animate() {
requestAnimationFrame(animate);
renderer.render(stage);
}
};
})();
I'm desperate lol, any help is appreciated.