It does not close the other screen

The Link to the aia

What i wanna do is when the airplane figure reached the vertical edge(the top of it y= 0-1) of the canvas to show up the next screen.

If i leave only reach edge even when the airplane figure reached horizontal edge it start the function inside it.

So the issue here some how is even i "closed" or did invisible the screen.

Still it shows up or sometimes as soon the next screen shows up(especially "japan screen") immediately it it shows the next screen.

The y coordinate not necessarily is 1...
Use the edge parameter instead... from the documentation Drawing and Animation

Edge here is represented as an integer that indicates one of eight directions north(1), northeast(2), east(3), southeast(4), south (-1), southwest(-2), west(-3), and northwest(-4).

Btw. what should happen, if another edge is reached?

Taifun

See Creating Animated Apps.

You want something to happen when the airplane sprite reaches the top of the screen in portrait mode? See 17-12 in the above link.

Instead of switching Screens, consider switching Canvas. See example where Canvas1 is your main screen and Canvas2 is your Germany screen. Your game might work more simply and reliable using virtual Screens. Something like this might work for you :slight_smile:

canvasOther

Even if do y to = 0 it will work out.
but the issue is, when switching from screen1 to screen2 anything alright.

but when switching from screen2 to screen instead of waiting until the image-sprite(airplane) reached the vertical edge y in the case it immediately switches from to screen4(as it already reached the vertical edge).

Another issue when reached to the last screen sometimes it starts again randomly showing screens(normally it should not do that since we closed those screen in the past and we never did call them.)

If i am not clear enough there is the aia file run it once and you will see what i mean.

Thanks in advance.

Thanks fort you reply.

That was my plan B instead of switching the screen to switch the canvas as you said.

But what is confusing me why are the screens even we called the event handler "close screen" still open when it reaches to the last screen sometimes it starts showing me again screen 3/4/5.(like as the never were closed) {in the last screen we do not call again the screens we just want how message that game is finished}.

And when i did install the unfinished app on my phone it crashed(cause of the memory consumption and properly some other issue cause it was necessary to restart the phone so i could use it again).

follow @SteveJG's advice

and your issues with switching screens are gone
from the first screenshot if another edge is reached you are opening screen Germany without closing the current screen...
my guess is in the end this crashes the app, because too many screens are open at the same time without closing the old screens, see also tip 1 here

Taifun

Thanks for the useful information.

I will try to do the work around, cause i thought more screen the code would look more clean.(since it shows less codes block)

But a question if "close screen" does not close the current screen witch function does it?
Since i thought when the function "close screen" is used the current screen(screen1) will be closed and only screen2(Germany will show up and would be the only one active).

Code below will close current screen, and open Screen2.

Code below will close current screen, return control to the screen which invoked it..
image

1 Like

It still did not work out but thanks you anyway.(while switching screens it shows for milisec other screens or it jumps to the wrong screen.)
I also tried Close application problem: In multiple screen, when I go to another screen, then back previous screen and press EXIT button. But it is not working properly - #3 by Anke
Same results.

Will use second method hide and show the canvas's.

Here the link if u curios how the whole projects looks so far.(where the issue is appearing with the screens are not closing properly)

To switch screens you generally have 2 options

  1. the Manager screen method App Inventor Tutorials and Examples: Manager Screen | Pura Vida Apps
  2. the Tribblehunter method or a variation App Inventor Tutorials and Examples: Multiple Screens | Pura Vida Apps

Taifun

You violated one of the prime rules of app development, assigning different data to different screens. Different screens are meant for different actions using different purposes.

I tried to open your project on the code AI2 server, and it failed to respond to screen switching requests in a timely fashion.

I uploaded your project to the Kodular Unchive tool (see image for URL) and got

Your project consists of sprites with images stuck to canvases in different screens, one screen per country.

This could have been handled in a single screen with a single Canvas and pool of reusable Sprites, based on two tables,

  • a country table
    • country name
    • country background image
    • country music
  • an attraction table
    • country name
    • attraction name
    • attraction image
    • attraction x
    • attraction y
    • attraction sound?

Here is a table based sample app for you to study:

1 Like

I tried like suggest her to do single screen with multiply canvas's.
It did work for two canvas's as soon i insert the third one it does not do what it should.

What my intentions are:
Start the Information game >> press ready >> show the notifier >> Invisible the first screen(home screen) >Show canvas one (CanvasUSA) and when the player gets to the edge, then show another notifier (or similar) that tells a little bit about US history and the moves on to the next canvas. When it collides with the object to show the history of the object and restarts the information game).>>> invisible the previous canvas> and each time when the next canvas shows up add +1 object that plane can collide(to make it harder).(this would be repeated until we would have 5 canvas).

All canvas are visible= false from the beginning.

You still need to learn how to use tables, to keep track of your Canvases and their adjacency.

There is no avoiding component reuse.