Skip to main content
BGuth.1
Senior
April 8, 2021
Question

How to move a dot along a specified path?

  • April 8, 2021
  • 7 replies
  • 1657 views

Hi,

In my demo project I have to move a dot along a L-shaped path continuously i.e. start over from beginning once the dot reaches end of the path. I would appreciate if you could point me to an example that explains hot to achieve this.

Thank you in advance.

This topic has been closed for replies.

7 replies

Romain DIELEMAN
ST Employee
April 8, 2021

Hi,

Are you looking for something like the project shared ? I used a circle widget instead of a button. You could use a shape widget instead. I would suggest having a deeper look at the moveAnimator functionality to understand how to work with it.

/Romain

BGuth.1
BGuth.1Author
Senior
April 8, 2021

Hi @Romain DIELEMAN​ , Thank you for the perfect example. It helps.

Sergey Bogaev
Associate
April 8, 2021

I would create an object (box for example) that will move and add MoveAnimator attribute to it.

0693W000008yxZ7QAI.png 

Then I would use this set of functions to move the object in the desired direction. (you can simply generate the object's movement in TouchGFX Designer Interactions and see an example of the generated code in xxxBase.cpp file)

To loop the movement I would use the handleTickEvent() function (this is a function that is called periodically), which you can override in your view file.

In this function, I would check the state of the animation and restart it when the movement finishes.

But perhaps there is a smarter solution :smirking_face:

BGuth.1
BGuth.1Author
Senior
April 8, 2021

Thank you @Sergey Bogaev​. I appreciate it.