I had some code for a score counter that was working fine the other week and now it doesn’t function. I would attach the game but I can’t because I just made this account but the part that is not working is the score counter. whenever the “bomb” hits the tank it should increase the score counter by 1 and now it doesn’t. Here is the code that is involved:
In the frame under load project.score = 0;
In the frame under update
if (project.score === 4) { gotoAndStop (77) }
And in each of the targets
if (this.hits(Bomb)){ project.score += 1 } if (this.hits(Bomb)){ this.y = 99999 this.x = 99999 }
Everything is correctly named but it just stopped working. Not sure if there was an update and this code doesn’t work now or If I am just bad at coding but any help would be appreciated.
hm, i really don’t know. it looks fine to me.
try this version, it has this.remove();
for the target instead of moving the target far away, and it has all the semicolons. make sure that you replace bomb
with the name of the bomb, with the correct capitalization.
if it still doesn’t work, maybe put your wick file in google drive, turn link sharing on, and give us the link. we might be able to help you that way.
LOAD (TANK)
project.score = 0;
UPDATE (TANK)
if(project.score === 4) {
gotoAndStop(77);
}
UPDATE (TARGETS)
if(this.hits(bomb)) {
project.score++;
this.remove();
}
Sadly that did not fix it.
https://drive.google.com/file/d/1a_XtJm0HTrinCGhdss_C2VICnG73dPsQ/view?usp=sharing
It is frame 74 where the problem is taking place.
Please somone help
it works perfectly for me…
does the collision happens? try a console.log(“tank bombed”); as test
then log the score
are you sure Bomb is available? or is it inside a clip?
I’ve had issues with using project.score as well when you jump around the timeline it seems to throw off all those variables. Maybe that’s the problem.
if you write
project.score
it’s an absolute path to the variable score present in the root of your project
You can imagine it as the first clip, father of all the others, when wickeditor starts.
if you create a new clip (let’s name it firstClip) it is nested in the project
to target variables inside firstClip you have to write
project.firstClip.variableName
I use project.score here as well. When you hit the snow pile and fail it takes you to a fail screen. Then you can click “retry.” It does a goto frame and then the game starts again. However, when you pick up presents it gives you double the points it’s supposed to give you. I have no idea what’s wrong with it.
It also work perfect for in my case.
Now, as a code newbie…
What’s wrong with it it looks fine
I think