Hello!
I attached an image, so you guys can visually see what I'm trying to accomplish.
My game is a music career simulator; for this particular context, the player selects the songwriting studio they wish to record in -- each studio has a varying level of success (i.e. the cheapest studio has a 40% success rate), and they complete the mini-game. Afterward, they are taken to this Summary Layout which'll show their score, and check if the songwriting session was successful or not.
I have a Spin Wheel sprite, with "Yes", "No", and "Spinning" animations. The "Yes" animation will, obviously, cause the spinner to land on a "Yes" square, and vice versa.
I thought the simplest way to accomplish this would be to set a local variable (called "Decider"), and compare against the "studioNum" value.
//I first set Decider to a number between 1 and 100.
On Start of Layout -> set Decider to int(random(1,100))
//Then, I compare...
On animation "Spinning" finished ->
If studioNum <= Decider -> set animation to "Yes";
Else -> set animation to "No";
For whatever reason, this logic doesn't work?
I tried adding another local variable (a boolean), called "isSongSuccess". Then, I tweaked my logic...
On Start of Layout -> set Decider to int(random(1,100))
And added some Javascript...(along with some debugging)
const ranNum = localVars.Decider;
const studioNum = localVars.StudioNum;
let isTrue = localVars.IsSongSuccess;
const debugText = runtime.objects.Text_Debug.getFirstInstance();
if (studioNum <= ranNum) {
isTrue = true;
debugText.text = `${studioNum} < ${ranNum} ${isTrue}`;
} else {
isTrue = false;
debugText.text = `${studioNum} < ${ranNum} ${isTrue}`;;
}
Knowing the boolean accurately displays true or false, I then tried using the boolean result to try and set the animation...
isSongSuccess True -> set animation to "Yes";
isSongSuccess False -> set animation to "No";
Yet still, it does not seem to work?? In the picture, you can see my debugging text at the bottom of the screenshot. The spin wheel SHOULD have played the "Yes" animation, but instead, it played the "No" animation.
Any help would be appreciated!