Array not working

Get help using Construct 2

Post » Tue Jun 25, 2013 10:43 am

Hi. I'm working on a childrens game, a little like Angry Birds, but the goal in my game is to help the fish get to freedom (i.e. the sea).

I've worked on some solutions for shoving the score. The usual textfield showing the score with a system font is a bit boring, so I tried web-fonts which are nice, but not consistent in all browsers. Chrome seem to have some issues with webfonts I think.

Anyway, I thought that maybe a simple system with 10 different bitmaps showing the numbers from 0 to 9 would do. I made an array to keep the four digits I need in place and made a test project just to see if I was on the right track. And the test project seem to do the job: Numbers test As you can see the number I put into the global variable "Score" is recreated and printed on screen as a nice row of numbers the way I want it to.

So far so good. But when I try to implement this into my real game it just won't work. Here's the game code: Save the fish r132

The function "ScoreNumbers" is called in the "EndOfLevel"-function in the EventsCore-sheet. You'll find it at the bottom of the sheet. As far as I can see the tokenat-expression doesn't find anything in the NumbersArray. But why not? I really hope somebody in this good community can help me!
B
14
S
4
G
3
Posts: 32
Reputation: 2,959

Post » Tue Jun 25, 2013 11:05 am

@SigmundO
First of all, your game looks nice ! I would love to see it finished :)

Then, I got it to work quite simply. Your problem is a misuse of the function tokenAt. First parameter needs to be a string, and you give it a number. If you just add a "str()" around it, it works, like this :
tokenat(str(Score), NumbersArray.Indeks, "")
B
17
S
8
G
4
Posts: 461
Reputation: 6,077

Post » Tue Jun 25, 2013 1:03 pm

Thank you!!! Happy now I am!
B
14
S
4
G
3
Posts: 32
Reputation: 2,959


Return to How do I....?

Who is online

Users browsing this forum: Congrats2u, FTGamingco, theinfomaven and 10 guests