[COCOS2D-X Remarks] cocos2dx get mobile phone screenshots and other accidental cancellation touch screen event processing method!

Source: Internet
Author: User

This site is originally written by Li huaming Himi. The reposted post must clearly indicate: Author: Sina Weibo: @ Li huaming Himi)
Reproduced from the black meters GameDev block) original link: http://www.himigame.com/iphone-cocos2d/1513.html

Click to subscribe to this blog's latest news! Notify you of the latest blog in time!


Recently, some children's shoes asked me how to obtain the iphone screenshot, so I will briefly discuss how to solve this problem.

In the cocos2dx engine, we can get it in AppDelegate. Users can switch the application to the background and return the application's event functions again. In this case, cocos2dx also allows us to intercept screens in the engine, and so on. This function can only handle events on mobile phones.

In fact, everyone should be familiar with the function of capturing user touch screens, as shown below:

1234 // default implements are used to call script callback if existvirtualboolccTouchBegan(CCTouch *pTouch, CCEvent *pEvent);virtualvoidccTouchMoved(CCTouch *pTouch, CCEvent *pEvent);virtualvoidccTouchEnded(CCTouch *pTouch, CCEvent *pEvent);

For example, there are three functions:

1. touchBegan: gets the function of the user's touch screen event.

2. touchMoved: gets the function of Sliding Screen events.

3. touchEnded: gets the function of the user's exit screen event.

In fact, the details of the shoes, or even those that do not understand the shoes, may be seen. In fact, there is also a function that can inherit and rewrite the touch screen event:

    virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent);

This function touchCancelled is used to obtain the function for canceling touch screen events caused by unexpected events. In fact, this function can not only obtain screenshots and other events that may lead to screen cancellation by accident, but also effectively avoid program exceptions between multiple contacts.

In addition, we recommend that you rewrite the ccTouchCancelled function to avoid unexpected events and program crashes when you rewrite the touch screen function of Himi!



This article is from the "Li huaming Himi" blog, please be sure to keep this source http://xiaominghimi.blog.51cto.com/2614927/1343348

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.