The solution to the problem that the genie disappears after using blink action in Cocos2d-x

Source: Internet
Author: User

After the wizard has performed the action with Blink, it disappears because there is the possibility that the sprite is just to the transparent part, so it is best to let the Genie setvisible show up after the sprite has performed the action.

How to resolve:

Format 1

Blink * hurt = blink::create (0.5, 5);

Write a callback function and call this callback function when the Blink action is completed

Callfunc *call2 = Callfunc::create ([this] () {
This->setvisible (TRUE);
});

This->runaction (Sequence::create (Hurt,call2, NULL));

Format 2

void Hero::afterhurt ()//The hero flashes after it may be gone, here to show it back

{

This->setvisible (TRUE);

}

After you use blink, you must wait for the wizard to finish, forcing the visual value of the wizard to be true before it can appear, otherwise it may appear blank

Blink * hurt = blink::create (0.5, 5);

finitetimeaction* action1 = Ccsequence::create (Hurt, callfunc::create (this, Callfunc_selector (Hero::afterhurt)), NULL);

This->runaction (Action1);

  1. void //hero flashing may be missing, here to display it again   
  2. {  
  3.      this true
  4.      wudi = false ;  
  5. }

[CPP]View PlainCopy 
  1. void  hero::hurt ()   
  2. {
  3. hp--;
  4.      if   (hp  >= 0)   
  5.      {  
  6.          //after using Ccblink must wait for the wizard to finish, force set the visual value of the wizard is true to display, otherwise there may be blank   
  7.          ccactioninterval*  action = ccblink::create (1.0f,  3);   
  8.          ccfinitetimeaction* action1 = ccsequence::create (Action, Cccallfunc::create (this ,  
  9.              callfunc_selector (Hero::afterHurt)), NULL);   
  10.          this
  11. }
  12. }

The solution to the problem that the genie disappears after using blink action in Cocos2d-x

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.