Continous horizontal animation of objects

| | August 6, 2015

We have to continously animate objects from right to left in a panel. The player has to pop the first object.

Animation

If the first object could not be destroyed by the player and it reaches the left border of the panel, the game is over:

Collision

We have experimented by implementing this using Android widgets.

The panel is a HorizontalScrollView and the objects are ImageViews placed in a LinearLayout. The HSV is continously scrolled using ObjectAnimators and when the first object is popped by the player, a new object is added to the LinerLayout. This solution has some problems: the LinearLayout gets infinitely big, adding new objects to our model and layouting them causes small hiccups and the animator speed is changable through the Android developer options which makes implementing high score pointless.

What would be a “standard” solution for games with an infinite animation where constant animation speed and good performance are critical? Is using native widgets possible with these requirements or should we throw everything away and use a Canvas?

Leave a Reply