Problem with counting score by using my own type of numbers

Do you have a sample project already started with 10 or 11 picture files with your digits, and a row of Image components in a Horizontal Arrangement?

That would make it easier to provide sample code.

In the meantime, here are some text blocks that are useful for picking digits out of a number:

  • length
  • segment

Also, look in the Blocks pallete for the Any Image blocks that can be used to address Image components in a list of Image component blocks.

Here is a sample for you ...
0 1 2 3 4 5 6 7 8 9 adaptive width


adaptive width font_counter.aia (14.8 KB) leading zero maximum digit count
(Digit images are courtesy of the Unicode math section)

Thank you very much for your advice. I'm basically still a newbie here, so it helped me a lot to understand the problem. Just out of curiosity I even applied it with small changes into a timer (for counting seconds). Everything was running smoothly.

However, I will have to do more research, because this seems to be not working in my case. I don't know, what I'm doing wrong. In your sample, the pictures with digits are shown after the button is clicked. I tried to apply your sample on a timer, so after timer.timer pictures with digits started changing. But I'm not quite sure, where should I apply it in my case. I only have a label for score counting, for changing score, I used procedure (but first, I started by initialization of score to 0). There is no 'when something do' I could use.

Also, I keep getting these errors:
Property setter was expecting a com.google.appinventor.components.runtime.Image component but got a String instead.

It would be awesome if you could help me with this.

You can also use a custom font in your label with this extension:

1 Like


Please export your project and post it here.

test_1.aia (35.3 KB)

I'm so sorry for answering you so late. Thank you for your time. I'm trying to learn how to use AI2 (different blocks) by creating this very simple game

I hope you are not color blind.
That would make using AI2 harder.


The component blocks are at the bottom of the palettes of their respective components.
The purple blocks are dead text, and unresponsive to attempts to use them to influence anything.

1 Like

Since you wisely use a procedure to update your call, that gives you a good place to put the code to update the list of images.


(I am assuming you call this procedure after every action that would change the score.)

1 Like

Thank you very much for your help. It works. :slight_smile:

I'm not colorblind, that was just part of my original idea. I created a list and defined each purple block as a certain picture of the digit, made them non-visible and wanted to show them only in case when they are called (when the text label has the same number as number value on the picture). And then when I tried your idea, I completely forgot to delete them and replace them by green blocks, instead I just renamed them. I'm sorry, that was a really stupid mistake.

Never let a good mistake go to waste

I am sorry for bothering you again, but I ran into another problem. When I try to run the app via AI Companion, everything is going well. However, I tried to download the app and launch it on other devices to see how it will look like on screens with different resolution. Everything is running without a problem, except for showing the score. It seems that there is some problem with those pictures of digits I replaced the text label because when I launch the app that counts score only with text label, it's running without a problem and I can see the current score. Is there something I overlooked?

This sounds like a problem in implementing responsive design with images.
(I mostly use the emulator, and draw what I need myself on Canvases, so I am not expert on this. @Italo is more expert at this than me.)

Here are some sources to research ...

2 Likes

What is the problem you are having with other screens? Please post a picture of how those numbers look.

Italo: the pictures of the numbers aren't even shown on other devices. And not only there. Even on the original device, where I have MIT AI2 Companion installed. When I run the project via AI2 Companion, it's running ok, but when I download the app and instal it to the mobile, app is working fine but without showing the numbers (pictures of numbers).

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

To get an image of your blocks, right click in the Blocks Editor and select "Download Blocks as Image". You might want to use an image editor to crop etc. if required. Then post it here in the community.

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

Hello, sorry for answering so late, but yesterday I didn't have time. Here are the relevant blocks. ABG helped me with this. It is perfectly working on AI2 Companion on every device, however, when I downloaded the app to the mobile manually, it still works, but it doesn't show the pictures of numbers, they supposed to show. I tried everything, but couldn't find what is behind this. I'm basically still a newbie in this area, so I'm really sorry if there is a simple solution I didn't see.



blocks3

Check this and let us know if it worked:

https://puravidaapps.com/info.php

remove the slashes


only the file component uses 2 slashes to access files from the assets

Taifun

1 Like

So the '//' prefix for Media image file names worked for me in the Companion, but does not work on devices? (:man_facepalming:)
Still in search of the mythical file name Rosetta Stone.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.