"Cocos2d-x notes" COCOS2DX get phone screenshots and other accidental cancellation of touch screen event processing Method!

Source: Internet
Author: User

Recently there are children's shoes asked me how to get to the iphone screenshot of the event, so this article will simply talk about how to deal with this problem.

In the COCOS2DX engine, we can obtain in Appdelegate, the user will apply into the background, and return to the application of the event function. So the corresponding, COCOS2DX also in the engine gives us to intercept the screen and other such only mobile phone should have event processing function.

In fact, everyone should be very familiar with the function of intercepting user touch screen, as follows:

1234 //default implements is used to call script callback if exist virtual bool cctouchbegan (Cctouch *ptouch, ccevent *pevent); virtual void cctouchmoved (Cctouch *ptouch, ccevent *pevent); virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);

As above three functions:

1.touchBegan: Gets the function of the user just touching the screen event.

2.touchMoved: Gets the function of the user sliding screen event.

3.touchEnded: Gets the function of the user leaving the screen event.

In fact, the details of children's shoes, or do not understand the children's shoes may have seen, in fact, touch screen event also has a function can inherit rewrite:

    virtual void cctouchcancelled (Cctouch *ptouch, ccevent *pevent);

This function touchcancelled the function of getting an unexpected event to cancel a touch-screen event. In fact, this function can not only get screenshots and other accidents caused by the touch screen cancellation of events, but also effectively avoid the multi-contact between the problems caused by program anomalies.

In addition Himi recommend rewriting the touchscreen function, be sure to rewrite the cctouchcancelled function to avoid unexpected events, causing the program to crash!

"Cocos2d-x notes" COCOS2DX get phone screenshots and other accidental cancellation of touch screen event processing Method!

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.