Note that there are some explanatory texts on larger screens.

plurals
  1. POanimation of an UIImageView run only once
    primarykey
    data
    text
    <p>I am writing a game. After attacker kills a soldier, a dropping UIImageView saying experience+1 will show. </p> <p>Now, the animation shows correctly when I kills 1st soldier, but <strong>not show</strong> when killing 2nd soldier and later.</p> <p>animation codes, method name is showGainXPAnimationAfterKillSoldier.</p> <pre><code> imgGainXPAfterKillSoldier.hidden = FALSE; [imgGainXPAfterKillSoldier.layer removeAllAnimations]; imgGainXPAfterKillSoldier.frame = CGRectMake(140, 220, 53, 19); // a loop to show animation. [UIView beginAnimations:nil context:nil]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIView setAnimationDuration:1.5]; //imgGainXPAfterKillSoldier.frame = CGRectMake(100, 200, 53, 19); CGAffineTransform transform = CGAffineTransformMakeTranslation(-112, 215); imgGainXPAfterKillSoldier.transform = transform; //imgGainXPAfterKillSoldier.alpha = 0.0f; [UIView commitAnimations]; </code></pre> <p>call animation codes,</p> <pre><code> if (killedSoldierCount&gt;0) { // add imgview to show gained XP. if (imgGainXPAfterKillSoldier) { MWLog(@"remove it!"); [imgGainXPAfterKillSoldier.layer removeAllAnimations]; [imgGainXPAfterKillSoldier removeFromSuperview]; } imgGainXPAfterKillSoldier.frame = CGRectMake(140, 220, 53, 19); imgGainXPAfterKillSoldier.hidden = TRUE; //imgGainXPAfterKillSoldier.alpha = 1.0f; [self.view addSubview:imgGainXPAfterKillSoldier]; switch (killedSoldierCount) { case 1: // show add experience animation after kill soldier. MWLog(@"kill a soldier, show XP+1 animation."); [self showGainXPAnimationAfterKillSoldier:1]; break; </code></pre> <p>what is the problem? Thanks in advance!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload