Android Tutorial Class example - Galaxy system emulation

Erel

Administrator
Staff member
Licensed User
This "galaxy" example simulates planets movements based on the gravity forces.

The purpose of this example is to demonstrate the usage of classes in a graphical program.



Each star holds a reference to a list of stars which are considered the star "moons". On each timer tick event the gravity force is calculated between each star and its moons and then all the stars are redrawn in their new position.

The user can change the gravity constant which affects the gravity force.

It is recommended to test this example on a real device (in Release mode).

This example can be easily modified to show more stars in different positions and velocities. This is an advantage of using classes. You can easily instantiate any number of Star objects.
 

Attachments

Top