The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsOk so here's what's going on. I have an item that you drag into a bag and when you do so it adds one to your score. Here's the code for the item(I'm pretty much a n00b at AS ):
on(release) {
this.stopDrag();
if(_root.bag.hitTest(this._x, this._y, true)) {
this.gotoAndStop("invis");
_global.playerScore = _global.playerScore + 1;
_root.scorebox.text = "Chickens: "+_global.playerScore;
}
else if(_root.bag.hitTest(this._x, this._y, false)) {
this.gotoAndPlay(1);
}
}
So basically when the item "goes into" the bag the global score variable is updated to whatever it currently is, plus one and the value in the dynamic text box is updated to display the global variable which has just been changed. Again, I'm pretty new to AS so I realize I could be way off with this code.
When I run the game and drag the items into the bag, rather than add one to the score it adds the number 1. So, after adding three items my score is 0111, instead of 3.
I'm not sure exactly what I need to fix so any help is greatly appreciated. Thanks!
AS: Main
Don't read this sentence.
Fixed:
on(release) {
this.stopDrag();
if(_root.bag.hitTest(this._x, this._y, true)) {
this.gotoAndStop("invis");
_global.playerScore = _global.playerScore + 1;
_root.scorebox.text = "Chickens: "+_global.playerScore;
}
else if(_root.bag.hitTest(this._x, this._y, false)) {
this.gotoAndPlay(1);
}
}
I'm pretty sure that's the exact code I posted..Did you change anything?
I tested it just to see and I'm still getting the same problem.
The score starts off at 0
You add one item and it's 01
you add another and it's 011
you add a third and it's 0111
AS: Main
Don't read this sentence.
At 6/13/07 04:34 PM, ChilliDog wrote: Did you change anything?
nah.
Forgot to mention, when the game starts I have this code:
_global.playerScore = "0";
_root.scorebox.text = "Chickens: "+_global.playerScore;
If that changes anything...
AS: Main
Don't read this sentence.
It should work if you change
_global.playerScore = "0";
to
_global.playerScore = 0;
Wow...I AM an idiot.
I tried putting () and "" around the +1 part of it but had totally forgot about that.
I guess I just put those "" in there out of habit?
Anyway, thanks a lot.
:I feel like a moron
AS: Main
Don't read this sentence.
_global.playerScore = 0
That should fix the problem. If you surround the 0 with "" than it thinks it is a string. Without "" it is a number.