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