Android Question Pause an App

ManuGarcia

Member
How can I pause (for 100 milliseconds, for example) to "simulate" an animation of images on continuous objects? I've tried Sleep and WaitFor but I can't get it to work. I put the code.
Thanks.

Do While tableroC(pulsadoX + 1, h) = 0
tablero(pulsadoX + 1, h - 1).Background = fondoBotones
Sleep(100)
tablero(pulsadoX + 1, h).Background = flechaAbajo
Sleep(100)
If h = 6 Then Exit
h = h + 1
Loop
 

ManuGarcia

Member
Thanks for the reply Erel. This loop is inside a sub that is called from Activity_create. I think that is causing me problems. The idea is to put a graphic on a button and when a certain time passes, that graphic disappears and appears on the next button, giving the sensation of a small animation.

I can't get it to work.

Sorry for the code...

B4X:
Do While tableroC(pulsadoX + 1, h) = 0
    tablero(pulsadoX + 1, h - 1).Background = fondoBotones
    Sleep(100)
    tablero(pulsadoX + 1, h).Background = flechaAbajo
    Sleep(100)
    If h = 6 Then Exit
    h = h + 1
Loop
 
Upvote 0

teddybear

Well-Known Member
Licensed User
You'd better post a small project.
 
Upvote 0

ManuGarcia

Member
Thanks to both.

The truth is that it's quite complex to explain... anyway, I've tried a timer but it doesn't work either. Or at least I don't know how to make it work... Here's a little video. When Santa pushes the sword, I would like it to show the fall more smoothly, not so abruptly. Any ideas? Thanks in advance.
 

Attachments

  • PapaNoel.zip
    83.4 KB · Views: 79
Upvote 0

teddybear

Well-Known Member
Licensed User
B4X:
Do While tableroC(pulsadoX + 1, h) = 0
    tablero(pulsadoX + 1, h - 1).Background = fondoBotones
    Sleep(100)
    tablero(pulsadoX + 1, h).Background = flechaAbajo
    Sleep(100)
    If h = 6 Then Exit
    h = h + 1
Loop
If I guess is correct, the code you want to move the sword from line 1 to 6,
Try doing replace your code with the following code
B4X:
tableroC(pulsadoX + 1, h).SetLayoutAnimated(600, tableroC(pulsadoX + 1, h).left, tableroC(pulsadoX + 1, 6).top,  tableroC(pulsadoX + 1, h).width, tableroC(pulsadoX + 1, h).height)
 
Last edited:
Upvote 0

ManuGarcia

Member
If I guess is correct, the code you want to move the sword from line 1 to 6,
Try doing replace your code with the following code
B4X:
tableroC(pulsadoX + 1, h).SetLayoutAnimated(600, tableroC(pulsadoX + 1, h).left, tableroC(pulsadoX + 1, 6).top,  tableroC(pulsadoX + 1, h).width, tableroC(pulsadoX + 1, h).height)
Let's see if I can try it this week... Thanks a lot. The loop is not always from 1 to 6... Sometimes there is an obstacle before. The truth is, it's much more complex. I already have the App almost finished, if I can then I put another video. If you notice, tableroC is an array of Int, while tablero is the array of buttoms. According to the number of the first I have to put a graph in the second. Thanks again. Best regards.
 
Upvote 0

teddybear

Well-Known Member
Licensed User
According to your code I know you would like to move the sword from h to 6.
the small project moves a image from the current position to the position you specified.
 

Attachments

  • move.zip
    470.9 KB · Views: 77
Upvote 0

ManuGarcia

Member
According to your code I know you would like to move the sword from h to 6.
the small project moves a image from the current position to the position you specified.
Thanks... i'm very busy.
I'll look at it as soon as I can. The game is already published... then I put the link.
All the best.
 
Upvote 0
Top