Skip to first unread message

mrs

unread,
May 7, 2019, 4:33:47 PM5/7/19
to MIT App Inventor Forum
So i want to know if theres a limitation about the amount of resources my apps can use from my phone. I do have a good phone, but my app (uses like 6 balls at the time in a canva, with a few sprites) goes with lagg. Im trying to optimitzate my app, but its there a solution or i just cant do anything?
Thanks

Chris Ward

unread,
May 7, 2019, 4:46:37 PM5/7/19
to MIT App Inventor Forum
Hello mrs

We would need to see your Blocks.
https://www.professorcad.co.uk/appinventortips#TipsBlocks  How to create an image of your Blocks and add it to your Forum Post

mrs

unread,
May 8, 2019, 12:59:17 AM5/8/19
to MIT App Inventor Forum
I can't acces the webpage. What foto you need to know about the code? I have roughly 700 blocs, but i try to use them only when needed (eg clockd only work for two seconds then are disabled)
Anyway, the true question, is there a limitation of the resources the app can fet from my phone?

mrs

unread,
May 8, 2019, 12:59:54 AM5/8/19
to MIT App Inventor Forum
What do you need*
Sorry autocorrector

Chris Ward

unread,
May 8, 2019, 10:33:52 AM5/8/19
to MIT App Inventor Forum
Hello mrs

You should be able to just click that link and be on the appropriate webpage, from anywhere in the World.........
https://www.professorcad.co.uk/appinventortips#TipsBlocks    How to create an image of your Blocks and add it to your Forum Post

In the Blocks view:
  1. right-mouse click in the workspace (not on a Block)
  2. in the pop-up menu, select "Clean up Blocks"
  3. in the pop-up menu, select "Download Blocks as Image" (produces a high quality PNG)
  4. in your forum post, click on the "insert image" button (the button is a tiny picture of a landscape and is next to the Link button)
There probably is a finite limit to the number of resources your App can use on the "average" smartphone, but 6 balls and a few sprites shouldn't come close - hence the need to see your Blocks, as it could be something, apparently innocuous, that creates a process bottleneck. 

The images you use for the sprites might be an issue - are they dimensionally the correct size for the App?

mrs

unread,
May 9, 2019, 8:47:59 AM5/9/19
to MIT App Inventor Forum

blocks.png

Ok, thats it. 

First of all, i dont know if its for the last update of the website, but it goes better. Anyway, its still a little slow when balls "spawn" (their x and y change, their image too (ill try to optimitzate the images) and their clock that lasts two seconds is activated and then desactivated)

Screenshot.png

To put you in some context, as im not english and the names for my variables and the use for the app could confusing, its an app with a firearm that you can move and aim with an objective that you can also move, basically. The photo uphere is a screenshot.


The arrows change the angle of the weapon, in mi idiom "arma", the main block.


The next block is to make the balls bounce, theres one block like it for every ball. 


Then, a timer. Every ball has a timer. When its "fired", the clock is activated and after something like 2 seconds the clock makes the ball invisible, sets its speed to 0 and deactivates the clock itself. Theyre named clock1, 2, etc...


The next block its the same but for a diferent type of shot (a buckshot), so it makes the same but for three balls at the same time. 


After that, theres the one that makes thatwhen you press the button "tipusdetir" (type of shot) and changes between buckshot and single shot.


The next one is the block of the target. When its collided, it calls the process "hit".


The global below, would traduce to "hits to the target" - you know what it does


After the repited blocks, the "cadenatObert2" sets the lock of the gun off, to make it able to shot


The "municio restant" is used to set the munition that is left once you shot, that sums up once the ball disapeared,and is shown in the upper left part of the canvas. (it uses six more sprites, one for ball, should i change it?)


Dont mind the "desbloquejarArmes"


The angle display is to show what angle is the weapon in at the bottom center button.


moure diana, traduces to move target. you should also know what it does


cadenatTancat does the same as cadenatObert but seting on the block of the weapon so it cant shot


TipusTirGlobal, would traduce to type of shot, and "senzill" to simple. the simple shot is the single one



Aaaand here we go: The arma block

Its a serie of statements, that says if the weapon sould shot, and what (buckshot, single)

First condition: The weapon block is off

Second one: resting amo is more than zero

Third one: The type of shot is single shot. Then: 

Checks wich one of the balls should fire, it goes through them to avoid repiting

The rest of the code is understandable in english


If its a buckshot: 

Does the same but with three balls at the same time.  


I don't have time for more, if you need something else comment it and i will explain whatever 

Thanks for all the time and for reading this all xD

Ghica

unread,
May 9, 2019, 9:09:35 AM5/9/19
to MIT App Inventor Forum
Maybe it helps to find out the cause of your performance problem if you post your .aia, so we can try a few things.
Anyway, whay do you have so many clocks? And, I do not know how many times SetMunicio is used. That can be optimized quite a lot.
Cheers, Ghica.

mrs

unread,
May 10, 2019, 9:16:38 AM5/10/19
to MIT App Inventor Forum
Here it is. How would you optimize the use of SetMunició?
And well, i use one clock for every ball, so they don't override and left the balls moving and visible all the time. 
Anyway i wouldnt say i just started using it, can i use less in that case? Thanks a lot for the time, Ghica.

provaProjectils.aia

mrs

unread,
May 10, 2019, 9:18:04 AM5/10/19
to MIT App Inventor Forum
Also, would you like me to traduce all the names and reupload the .aia or are you fine with that?

Ghica

unread,
May 10, 2019, 9:46:28 AM5/10/19
to MIT App Inventor Forum
I think I can guess most of the meanings, but I am not sure why you think it is to slow, and what I should do to see it.
Cheers, Ghica.

Ghica

unread,
May 10, 2019, 4:49:01 PM5/10/19
to MIT App Inventor Forum
I am really not sure why your project would be slow.
Having so many clocks does not help, although it seems that you only fire one at the time.
I tried to bring some sanity in your code, by taking out repetition and redundancy.
For example, you disable each cock before you enable it. Seems redundant to me.
Also, if numProjetil = 3 (for example) you test whether it might be > 6, which is of course impossible.
Look at my code. I used a lot of any blocks, which might make it more difficult to understand. (It may not work even, because I am not really sure what to look at).
If you have questions, ask. And if it is still slow, please tell more precisely when that happens.
Cheers, Ghica.

provaProjectils_copy.aia
Reply all
Reply to author
Forward
0 new messages