Nothing much is impossible.

You seem to be overcomplicating your problems:

Problem 1: Calculating the result at the right time.
Solution 1: Define the random numbers for each state of each TextView
BEFORE you even start animating...benefit of that is you can calculate
the result BEFORE you even start animating. In doing so you have
affectively put Problem 1 out of existence. This is what Mark
suggested.

Problem 2: Knowing when the dies have finished animating.
Solution 2: If you're having trouble using an AnimationListener, why
not try a simpler approach whereby you use a state pattern for each
die and manually control the visual state of each die? Then you not
only know when the "animation" has finished, you also know when the
"animation" is at step 1, step 2, step 3, etc.

On Nov 15, 4:00 am, gontran <[email protected]> wrote:
> Ok, I get your point, but my problem is both displaying and
> calculating the result at the right time because in my game, you roll
> dices to get an asset of points, to attack another player... So
> depending on the state of the game, the instructions run after each
> rolls are not always the same. so after each roll, I have to display
> the sum and other informations depending on the state of the game and
> maybe changing the state (I use the state design pattern).
>
> For me, the best solution would be to make a single animation to
> animate the six dices, but correct me if I'm wrong, it's impossible to
> make each dice rotate on itself with a single animation.
>
> Anyway, thank you for your time.
>
> On 14 nov, 16:36, Mark Murphy <[email protected]> wrote:
>
> > On Sun, Nov 14, 2010 at 10:25 AM, gontran <[email protected]> 
> > wrote:
> > > Thank you Mark for your answer, but could-you be more specific please?
> > > What do you mean by "pre-compute"?
>
> > Pre-compute = compute in advance.
>
> > If I understand correctly, you have 30 random numbers (six dice, five
> > state changes). You want the sum of the last six random numbers.
>
> > Right now, you appear to be generating those random numbers on the
> > fly. Rather than do that, compute them in advance. Then, you do not
> > have to worry about "wait that each animation has ended to calculate
> > the sum of each roll", because you already know the values.
>
> > Or, just pre-compute the last six random numbers (the ones you need to
> > sum), so on your last state change, you go to the pre-computed value
> > rather than generating another random number on the fly.
>
> > If your problem is more about displaying the sum at the right time,
> > more so than calculating it, just use a single AnimationListener on
> > one of your dice. If they are all animating simultaneously, they will
> > all end simultaneously, so just pick one and use that to time the
> > display of your sum.
>
> > --
> > Mark Murphy (a Commons 
> > Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> > Android 2.2 Programming Books:http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to