Confira o Videos Épicos #45!
22 Respostas   693 Visualizações
0 Membros e 1 Visitante estão vendo este tópico.
//-----------------------------------------------------------------------------// Galv's Picture Animations//-----------------------------------------------------------------------------// For: RPGMAKER MV// GALV_PictureAnims.js//-----------------------------------------------------------------------------// 2017-01-18 - Version 1.2 - fixed a crash when erasing picture before battle// 2016-08-22 - Version 1.1 - fixed crash when transferring to another map// 2016-08-17 - Version 1.0 - release//-----------------------------------------------------------------------------// Terms can be found at:// galvs-scripts.com//-----------------------------------------------------------------------------var Imported = Imported || {};Imported.Galv_PictureAnims = true;var Galv = Galv || {}; // Galv's main objectGalv.PIC = Galv.PIC || {}; // Galv's stuff//-----------------------------------------------------------------------------/*: * @plugindesc (v.1.2) Play database animations on pictures made with "Show Picture" * * @author Galv - galvs-scripts.com * * @param * @desc * @default * * @help * Galv's Picture Animations * ---------------------------------------------------------------------------- * This plugin allows you to play animation on pictures created with the * "Show Picture" event command. To do this, use a script call: * * Galv.PIC.anim(picId,animId); // picId = Picture number to play anim on * // animId = animation id from the database * *///-----------------------------------------------------------------------------// CODE STUFFS//-----------------------------------------------------------------------------(function() {Galv.PIC.anim = function(picId,animId) { if ($gameScreen._pictures[picId]) $gameScreen._pictures[picId]._animationId = animId;};Galv.PIC.Sprite_Picture_initialize = Sprite_Picture.prototype.initialize;Sprite_Picture.prototype.initialize = function(pictureId) { this._animationSprites = []; this._effectTarget = this; this._hiding = false; Galv.PIC.Sprite_Picture_initialize.call(this,pictureId);};Galv.PIC.Sprite_Picture_updateOther = Sprite_Picture.prototype.updateOther;Sprite_Picture.prototype.updateOther = function() { Galv.PIC.Sprite_Picture_updateOther.call(this); this.updateAnimation(); this.updateVisibility(); this.updateAnimationSprites();};Sprite_Picture.prototype.updateAnimation = function() { this.setupAnimation(); if (!this.isAnimationPlaying()) { this._animationPlaying = false; }};Sprite_Picture.prototype.setupAnimation = function() { var pic = this.picture(); if (pic && pic._animationId > 0) { this._animId = $gameScreen._pictures[this._pictureId]._animationId; var animation = $dataAnimations[this._animId]; this.startAnimation(animation, false, 0); $gameScreen._pictures[this._pictureId]._animationId = 0; this._animationPlaying = true; }};Sprite_Picture.prototype.startAnimation = function(animation, mirror, delay) { var sprite = new Sprite_Animation(); sprite.setup(this._effectTarget, animation, mirror, delay); sprite.opaque = true; this.parent.addChild(sprite); this._animationSprites.push(sprite);};Sprite_Picture.prototype.isAnimationPlaying = function() { return this._animationSprites.length > 0;};Sprite_Picture.prototype.updateAnimationSprites = function() { if (this._animationSprites.length > 0) { var sprites = this._animationSprites.clone(); this._animationSprites = []; for (var i = 0; i < sprites.length; i++) { var sprite = sprites[i]; if (sprite.isPlaying()) { this._animationSprites.push(sprite); } else { sprite.remove(); } } }};Sprite_Picture.prototype.hide = function() { this._hiding = true;};Sprite_Picture.prototype.show = function() { this._hiding = false;};Sprite_Picture.prototype.updateVisibility = function() { this.visible = !this._hiding;};})();
Eu tava vendo aqui o corpo do script e achei mais vantajoso fazer um do zero. Tó.Esse aí vai esperar a animação terminar, porém os testes que eu realizei nele foram poucos. Testa aí e me diz se tá funcionando como queira.
Poderia me mostrar como está a página do evento onde você está usando o comando?
Uncaught TypeError: Cannot read property 'width' of nullrpg_managers.js:1589 file:///C:/Users/Jefferson/Documents/Games/TCG/js/rpg_core.js 3386rpg_core.js:3386 Uncaught TypeError: Cannot read property 'width' of null
Sprite.prototype._onBitmapLoad = function() { if (this._frame.width === 0 && this._frame.height === 0) { this._frame.width = this._bitmap.width; this._frame.height = this._bitmap.height; } this._refresh();};
this._frame.width = this._bitmap.width;
Hm, entendo. É que o plugin foi feito para ser usado no chamar script, daí eu teria que ver exatamente onde tu tá usando o código pra poder ver o que tá causando "incompatibilidade" ahuahaE que nada, 1000 linhas é pouco comparado ao que eu já vi :v
Aqui. Eu fiz uma pequena alteração que vai fazer ele ignorar o comando caso a imagem não tenha sido criada ainda.Como já disse antes, eu não recomendo que você use ele diretamente dentro do comando $gameScreen.showPicture, visto que esse comando apenas cria as configurações da imagem (como o nome, posição, escala, e etc...), já a imagem em si é criada apenas depois, resultando no erro, sendo que para mostrar uma animação na imagem, é necessário que ela já tenha sido criada.
Ah... nesse caso era só usar o comando Wait...Spoiler[close]
É o comando wait do editor mesmo, ou tu tá querendo usar ele via script? Se for o caso, i'll do it o/