Aircraft War Development 04 bullet collision detection with enemy aircraft

Source: Internet
Author: User

Collision detection of enemy and player bullets first:

Code:

Gamelayer . h

void Gamelayer::update (float dt) {for (int i = 0; i < m_penermyvec.size (), i++) {Sprite * Pene = m_penermyvec.at (i); for ( int j = 0; J < M_pplayerbullet.size (); j + +) {Sprite * Pbul = m_pplayerbullet.at (j); if (Pene->getboundingbox (). Intersectsrect (Pbul->getboundingbox ())) {pene->stopallactions ();p bul->stopallactions ();p ene->runaction (Sequence::create (FadeOut::create (0.5f) , Removeself::create (True), nullptr));p bul->runaction (Removeself::create (true)); M_penermyvec.eraseobject (PEne ); M_pplayerbullet.eraseobject (Pbul); i--; j--;}}}

This is the basic function of the game logic is finished, the following will be the main research under the bomb screen.

Source: http://pan.baidu.com/s/1bntWUC3

only Class and the Resource


Aircraft War Development 04 bullet collision detection with enemy aircraft

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.