
今天遇到坑,就是在实现多点触摸时不放几个手指到屏幕上,获取的触摸点得个数都是1。最终解决方案:
找到iOS文件RootVIEwController.mm,添加
[eaglVIEw setMultipletouchEnabled:YES]
全部代码如下:
#import "RootVIEwController.h"#import "cocos2d.h"#import "platform/ios/CCEAGLVIEw-ios.h"@implementation RootVIEwController/* // The designated initializer. OverrIDe if you create the controller programmatically and want to perform customization that is not appropriate for vIEwDIDLoad. - (ID)initWithNibname:(Nsstring *)nibnameOrNil bundle:(NSBundle *)nibBundleOrNil { if ((self = [super initWithNibname:nibnameOrNil bundle:nibBundleOrNil])) { // Custom initialization } return self; } */// Implement loadVIEw to create a vIEw hIErarchy programmatically,without using a nib.- (voID)loadVIEw { // Initialize the CCEAGLVIEw CCEAGLVIEw *eaglVIEw = [CCEAGLVIEw vIEwWithFrame: [UIScreen mainScreen].bounds pixelFormat: (__brIDge Nsstring *)cocos2d::GLVIEwImpl::_pixelFormat depthFormat: cocos2d::GLVIEwImpl::_depthFormat preserveBackbuffer: NO sharegroup: nil multiSampling: NO numberOfSamples: 0 ]; //将NO改为YES就可以使用多点触摸啦! [eaglVIEw setMultipletouchEnabled:YES]; // Set EAGLVIEw as vIEw of RootVIEwController self.vIEw = eaglVIEw;}// Implement vIEwDIDLoad to do additional setup after loading the vIEw,typically from a nib.- (voID)vIEwDIDLoad { [super vIEwDIDLoad];}- (voID)vIEwWillAppear:(BOol)animated { [super vIEwWillAppear:animated];}- (voID)vIEwDIDdisappear:(BOol)animated { [super vIEwDIDdisappear:animated];}// For ios6,use supportedInterfaceOrIEntations & shouldautorotate instead#ifdef __IPHONE_6_0- (NSUInteger) supportedInterfaceOrIEntations{ return UIInterfaceOrIEntationMaskAllButUpsIDeDown;}#endif- (BOol) shouldautorotate { return YES;}- (voID)dIDRotateFromInterfaceOrIEntation:(UIInterfaceOrIEntation)fromInterfaceOrIEntation { [super dIDRotateFromInterfaceOrIEntation:fromInterfaceOrIEntation]; auto glvIEw = cocos2d::Director::getInstance()->getopenGLVIEw(); if (glvIEw) { CCEAGLVIEw *eaglvIEw = (__brIDge CCEAGLVIEw *)glvIEw->getEAGLVIEw(); if (eaglvIEw) { CGSize s = CGSizeMake([eaglvIEw getWIDth],[eaglvIEw getHeight]); cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.wIDth,(int) s.height); } }}//fix not hIDe status on ios7- (BOol)prefeRSStatusbarHIDden { return YES;}- (voID)dIDReceiveMemoryWarning { // Releases the vIEw if it doesn't have a supervIEw. [super dIDReceiveMemoryWarning]; // Release any cached data,images,etc that aren't in use.}@end总结
以上是内存溢出为你收集整理的cocos2d-x 3.16 ios开启多点触摸全部内容,希望文章能够帮你解决cocos2d-x 3.16 ios开启多点触摸所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)