ManuGarcia Member Oct 20, 2022 #1 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
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
Erel B4X founder Staff member Licensed User Longtime User Oct 21, 2022 #2 Please use [code]code here...[/code] tags when posting code. Sleep will cause the sub execution to pause and later resume. It will not affect other events. Upvote 0
Please use [code]code here...[/code] tags when posting code. Sleep will cause the sub execution to pause and later resume. It will not affect other events.
ManuGarcia Member Oct 21, 2022 #3 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... Code: Copy 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
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... Code: Copy 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
Serge Bertet Active Member Licensed User Longtime User Oct 22, 2022 #4 Not clear to me what you plan to do but I think this is a job for a timer. Upvote 0
teddybear Well-Known Member Licensed User Oct 22, 2022 #5 You'd better post a small project. Upvote 0
ManuGarcia Member Oct 22, 2022 #6 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 PapaNoel.zip 83.4 KB · Views: 373 Upvote 0
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.
Serge Bertet Active Member Licensed User Longtime User Oct 23, 2022 #7 ManuGarcia said: giving the sensation of a small animation. Click to expand... There is a internal library named "Animation" to smooth movements of views. Maybe a way for you to acheive what you want. Upvote 0
ManuGarcia said: giving the sensation of a small animation. Click to expand... There is a internal library named "Animation" to smooth movements of views. Maybe a way for you to acheive what you want.
teddybear Well-Known Member Licensed User Oct 23, 2022 #8 ManuGarcia said: Code: Copy 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 Click to expand... 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: Copy 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: Oct 23, 2022 Upvote 0
ManuGarcia said: Code: Copy 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 Click to expand... 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: Copy 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)
ManuGarcia Member Oct 24, 2022 #9 Serge Bertet said: There is a internal library named "Animation" to smooth movements of views. Maybe a way for you to acheive what you want. Click to expand... I also tried it and it doesn't work. I'll keep trying. Thanks a lot. Upvote 0
Serge Bertet said: There is a internal library named "Animation" to smooth movements of views. Maybe a way for you to acheive what you want. Click to expand... I also tried it and it doesn't work. I'll keep trying. Thanks a lot.
ManuGarcia Member Oct 24, 2022 #10 teddybear said: 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: Copy 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) Click to expand... 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 said: 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: Copy 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) Click to expand... 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.
teddybear Well-Known Member Licensed User Oct 25, 2022 #11 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 move.zip 470.9 KB · Views: 384 Upvote 0
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.
ManuGarcia Member Nov 11, 2022 #12 teddybear said: 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. Click to expand... 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
teddybear said: 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. Click to expand... 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.