So first I should probably mention I'm completely new to scripting in any form, and all my knowledge comes from video tutorials and a small amount of online research. I've been trying to apply what I learn and do something more than what I was shown with it, to be sure I'm actually learning something, which led to this more-complex-than-intended variation on a plugin to overlay a tiled sprite on the title screen (as per one of Soul's video tutorials). The intent is to be able to not only scroll the image in custom directions/speeds, but to have the option of "bouncing" or "wiggling" as well (reversing movement along the X and/or Y axes at set intervals). The result so far is that movement of the tilesprite is handled exactly as I intended it to be, but for some reason it seems to be setting one of my parameters to "true" regardless of what I set it to in the plugin manager.
Here's the script so far:
Even with the little I know, I'm pretty sure I can cut some things out or work in shortcuts, but I'm more concerned about the mystery around the "myBounce" variable; I've been testing it with the Wiggle parameter set to true and the Bounce parameter set to false, but after adding my debug console logs to the end, it's telling me both are "true" when i start my test play. Am I missing something, is it pulling the value from somewhere else? Any help understanding this would be appreciated.
Edit: I've done a little further testing, and apparently no matter what I set the Wiggle and Bounce parameters to, they're responding true to the variables assigned to them. I tried setting them both to false manually, in the script, and they stayed false, so apparently it is definitely happening when it grabs that value from that parameter, but I don't understand why.
Here's the script so far:
//====================================================================
// Sprite Test.js
//====================================================================
/*:
* @param Image
* @desc The image you are using
* @default Image
*
* @param Image Opacity
* @desc The level of opacity for your image
* @default 0
*
* @param X Axis Origin
* @desc The starting position of the image on the X axis
* @default 0
*
* @param Y Axis Origin
* @desc The starting position of the image on the Y axis
* @default 0
*
* @param X Axis Increment
* @desc The speed of the image's horizontal movement, in pixels per increment
* @default 0
*
* @param Y Axis Increment
* @desc The speed of the image's vertical movement, in pixels per increment
* @default 0
*
* @param Wiggle
* @desc Periodically reverse direction along the X axis
* @default false
*
* @param Bounce
* @desc Periodically reverse direction along the Y axis
* @default false
*
* @param Wiggle Distance
* @desc Number of increments between direction change along X axis
* @default 5
*
* @param Bounce Distance
* @desc Number of increments between direction change along Y axis
* @default 5
*/
var params = PluginManager.parameters("Sprite Test");
var my_image_name = String(params['Image'] || "Image");
var myImageOpacity = Number(params['Image Opacity'] || 0);
var myXPos = Number(params['X Axis Origin'] || 0);
var myYPos = Number(params['Y Axis Origin'] || 0);
var myXIncrement = Number(params['X Axis Increment'] || 0);
var myYIncrement = Number(params['Y Axis Increment'] || 0);
var myWiggle = Boolean(params['Wiggle'] || false);
var myBounce = Boolean(params['Bounce'] || false);
var myWiggleDistance = Number(params['Wiggle Distance'] || 5);
var myBounceDistance = Number(params['Bounce Distance'] || 5);
var myWiggleCount = 0;
var myBounceCount = 0;
var myWiggleReverse = false;
var myBounceReverse = false;
var createALIAS = Scene_Title.prototype.create;
var updateALIAS = Scene_Title.prototype.update;
Scene_Title.prototype.myImage;
Scene_Title.prototype.create = function () {
createALIAS.call(this);
this.create_my_image();
};
Scene_Title.prototype.create_my_image = function () {
this.myImage = new TilingSprite();
this.myImage.bitmap = ImageManager.loadPicture(my_image_name);
this.myImage.opacity = myImageOpacity;
this.myImage.x = myXPos;
this.myImage.y = myYPos;
this.myImage.move(0, 0, Graphics.width, Graphics.height);
this.addChild(this.myImage);
};
Scene_Title.prototype.update = function () {
updateALIAS.call(this);
if (myWiggle === true && myBounce === true) {
if (myWiggleReverse === false && myWiggleCount < myWiggleDistance) {
this.myImage.origin.x += myXIncrement;
myWiggleCount += 1;
} else if (myWiggleReverse === false && myWiggleCount === myWiggleDistance) {
myWiggleReverse = true;
} else if (myWiggleReverse === true && myWiggleCount !== 0) {
this.myImage.origin.x -= myXIncrement;
myWiggleCount -= 1;
} else if (myWiggleReverse === true && myWiggleCount === 0) {
myWiggleReverse = false;
}
if (myBounceReverse === false && myBounceCount < myBounceDistance) {
this.myImage.origin.y += myYIncrement;
myBounceCount += 1;
} else if (myBounceReverse === false && myBounceCount === myBounceDistance) {
myBounceReverse = true;
} else if (myBounceReverse === true && myBounceCount !== 0) {
this.myImage.origin.y -= myYIncrement;
myBounceCount -= 1;
} else if (myBounceReverse === true && myBounceCount === 0) {
myBounceReverse = false;
}
} else if (myWiggle === true && myBounce === false) {
if (myWiggleReverse === false && myWiggleCount < myWiggleDistance) {
this.myImage.origin.x += myXIncrement;
myWiggleCount += 1;
} else if (myWiggleReverse === false && myWiggleCount === myWiggleDistance) {
myWiggleReverse = true;
} else if (myWiggleReverse === true && myWiggleCount !== 0) {
this.myImage.origin.x -= myXIncrement;
myWiggleCount -= 1;
} else if (myWiggleReverse === true && myWiggleCount === 0) {
myWiggleReverse = false;
}
this.myImage.origin.y += myYIncrement;
} else if (myWiggle === false && myBounce === true) {
if (myBounceReverse === false && myBounceCount < myBounceDistance) {
this.myImage.origin.y += myYIncrement;
myBounceCount += 1;
} else if (myBounceReverse === false && myBounceCount === myBounceDistance) {
myBounceReverse = true;
} else if (myBounceReverse === true && myBounceCount !== 0) {
this.myImage.origin.y -= myYIncrement;
myBounceCount -= 1;
} else if (myBounceReverse === true && myBounceCount === 0) {
myBounceReverse = false;
}
this.myImage.origin.x += myXIncrement;
} else if (myWiggle === false && myBounce === false) {
this.myImage.origin.x += myXIncrement;
this.myImage.origin.y += myYIncrement;
}
};
console.log("myWiggle = " + myWiggle);
console.log("myBounce = " + myBounce);
// Sprite Test.js
//====================================================================
/*:
* @param Image
* @desc The image you are using
* @default Image
*
* @param Image Opacity
* @desc The level of opacity for your image
* @default 0
*
* @param X Axis Origin
* @desc The starting position of the image on the X axis
* @default 0
*
* @param Y Axis Origin
* @desc The starting position of the image on the Y axis
* @default 0
*
* @param X Axis Increment
* @desc The speed of the image's horizontal movement, in pixels per increment
* @default 0
*
* @param Y Axis Increment
* @desc The speed of the image's vertical movement, in pixels per increment
* @default 0
*
* @param Wiggle
* @desc Periodically reverse direction along the X axis
* @default false
*
* @param Bounce
* @desc Periodically reverse direction along the Y axis
* @default false
*
* @param Wiggle Distance
* @desc Number of increments between direction change along X axis
* @default 5
*
* @param Bounce Distance
* @desc Number of increments between direction change along Y axis
* @default 5
*/
var params = PluginManager.parameters("Sprite Test");
var my_image_name = String(params['Image'] || "Image");
var myImageOpacity = Number(params['Image Opacity'] || 0);
var myXPos = Number(params['X Axis Origin'] || 0);
var myYPos = Number(params['Y Axis Origin'] || 0);
var myXIncrement = Number(params['X Axis Increment'] || 0);
var myYIncrement = Number(params['Y Axis Increment'] || 0);
var myWiggle = Boolean(params['Wiggle'] || false);
var myBounce = Boolean(params['Bounce'] || false);
var myWiggleDistance = Number(params['Wiggle Distance'] || 5);
var myBounceDistance = Number(params['Bounce Distance'] || 5);
var myWiggleCount = 0;
var myBounceCount = 0;
var myWiggleReverse = false;
var myBounceReverse = false;
var createALIAS = Scene_Title.prototype.create;
var updateALIAS = Scene_Title.prototype.update;
Scene_Title.prototype.myImage;
Scene_Title.prototype.create = function () {
createALIAS.call(this);
this.create_my_image();
};
Scene_Title.prototype.create_my_image = function () {
this.myImage = new TilingSprite();
this.myImage.bitmap = ImageManager.loadPicture(my_image_name);
this.myImage.opacity = myImageOpacity;
this.myImage.x = myXPos;
this.myImage.y = myYPos;
this.myImage.move(0, 0, Graphics.width, Graphics.height);
this.addChild(this.myImage);
};
Scene_Title.prototype.update = function () {
updateALIAS.call(this);
if (myWiggle === true && myBounce === true) {
if (myWiggleReverse === false && myWiggleCount < myWiggleDistance) {
this.myImage.origin.x += myXIncrement;
myWiggleCount += 1;
} else if (myWiggleReverse === false && myWiggleCount === myWiggleDistance) {
myWiggleReverse = true;
} else if (myWiggleReverse === true && myWiggleCount !== 0) {
this.myImage.origin.x -= myXIncrement;
myWiggleCount -= 1;
} else if (myWiggleReverse === true && myWiggleCount === 0) {
myWiggleReverse = false;
}
if (myBounceReverse === false && myBounceCount < myBounceDistance) {
this.myImage.origin.y += myYIncrement;
myBounceCount += 1;
} else if (myBounceReverse === false && myBounceCount === myBounceDistance) {
myBounceReverse = true;
} else if (myBounceReverse === true && myBounceCount !== 0) {
this.myImage.origin.y -= myYIncrement;
myBounceCount -= 1;
} else if (myBounceReverse === true && myBounceCount === 0) {
myBounceReverse = false;
}
} else if (myWiggle === true && myBounce === false) {
if (myWiggleReverse === false && myWiggleCount < myWiggleDistance) {
this.myImage.origin.x += myXIncrement;
myWiggleCount += 1;
} else if (myWiggleReverse === false && myWiggleCount === myWiggleDistance) {
myWiggleReverse = true;
} else if (myWiggleReverse === true && myWiggleCount !== 0) {
this.myImage.origin.x -= myXIncrement;
myWiggleCount -= 1;
} else if (myWiggleReverse === true && myWiggleCount === 0) {
myWiggleReverse = false;
}
this.myImage.origin.y += myYIncrement;
} else if (myWiggle === false && myBounce === true) {
if (myBounceReverse === false && myBounceCount < myBounceDistance) {
this.myImage.origin.y += myYIncrement;
myBounceCount += 1;
} else if (myBounceReverse === false && myBounceCount === myBounceDistance) {
myBounceReverse = true;
} else if (myBounceReverse === true && myBounceCount !== 0) {
this.myImage.origin.y -= myYIncrement;
myBounceCount -= 1;
} else if (myBounceReverse === true && myBounceCount === 0) {
myBounceReverse = false;
}
this.myImage.origin.x += myXIncrement;
} else if (myWiggle === false && myBounce === false) {
this.myImage.origin.x += myXIncrement;
this.myImage.origin.y += myYIncrement;
}
};
console.log("myWiggle = " + myWiggle);
console.log("myBounce = " + myBounce);
Even with the little I know, I'm pretty sure I can cut some things out or work in shortcuts, but I'm more concerned about the mystery around the "myBounce" variable; I've been testing it with the Wiggle parameter set to true and the Bounce parameter set to false, but after adding my debug console logs to the end, it's telling me both are "true" when i start my test play. Am I missing something, is it pulling the value from somewhere else? Any help understanding this would be appreciated.
Edit: I've done a little further testing, and apparently no matter what I set the Wiggle and Bounce parameters to, they're responding true to the variables assigned to them. I tried setting them both to false manually, in the script, and they stayed false, so apparently it is definitely happening when it grabs that value from that parameter, but I don't understand why.
Last edited: