mardi 8 septembre 2015

Observer pattern with animation

I am developing an android game and try to seperate as much logic as i can from the ui.

I have a view where the user can move tubes by swiping. I use a model to hold the state of the tubes and an observer pattern to bring the model together with the view. So if the user swipes a tube no tube swipe animation is called, only the model is called to change the tubes state. Then the view is notified by the model to do an update.

The view.

Now its easy to change the view to display the new tubes state.

There is only one problem. I want to have a nice animation which shows which tube moved from which point to which point. There are some problems i have to achive this goal.

  • The model only contains the current state of the tubes. Should it also contain previous ones to know how to do the animation?
  • If the user swipes again while there is an active animation. What should happen then?

My actually question is, how can i deal with the observer pattern and animation combined, or is there a better way to achieve my goal?

Aucun commentaire:

Enregistrer un commentaire