axmolengine / axmol

Axmol Engine – A Multi-platform Engine for Desktop, XBOX (UWP) and Mobile games. (A fork of Cocos2d-x-4.0)
https://axmol.dev
MIT License
922 stars 205 forks source link

EventListenerTouchAllAtOnce incorrect #1358

Closed NgVThangBz closed 1 year ago

NgVThangBz commented 1 year ago
rh101 commented 1 year ago

Would you care to state how you resolved this issue? Was it an issue in your own code, or a bug in Axmol?

NgVThangBz commented 1 year ago

you can see it here: https://github.com/axmolengine/axmol/discussions/1356#discussioncomment-7118266 just need : [__glView setMultipleTouchEnabled:YES]; you can enable it default

rh101 commented 1 year ago

you can enable it default

It's actually already in the code, and enabled by default in the view creation, but I just found out that it's being explicitly disabled in the project code:

You can see here that it is enabled:

bool GLViewImpl::initWithRect(std::string_view viewName, const Rect& rect, float frameZoomFactor)
{
    CGRect r = CGRectMake(rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);
    convertAttrs();
    CCEAGLView* eaglView = [CCEAGLView viewWithFrame:r
                                         pixelFormat:(NSString*)_pixelFormat
                                         depthFormat:_depthFormat
                                  preserveBackbuffer:NO
                                          sharegroup:nil
                                       multiSampling:NO
                                     numberOfSamples:0];

    // Not available on tvOS
#if !defined(AX_TARGET_OS_TVOS)
    [eaglView setMultipleTouchEnabled:YES];
#endif

    _screenSize.width = _designResolutionSize.width = [eaglView getWidth];
    _screenSize.height = _designResolutionSize.height = [eaglView getHeight];
    //    _scaleX = _scaleY = [eaglView contentScaleFactor];

    _eaglView = eaglView;

    return true;
}

But then it is disabled in several places: image

Such as the RootViewController.mm of the cpp and lua project templates:

// 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*)ax::GLViewImpl::_pixelFormat
                                         depthFormat:ax::GLViewImpl::_depthFormat
                                  preserveBackbuffer:NO
                                          sharegroup:nil
                                       multiSampling:ax::GLViewImpl::_multisamplingCount > 0 ? YES : NO
                                     numberOfSamples:ax::GLViewImpl::_multisamplingCount];

    // Enable or disable multiple touches
#if !defined(AX_TARGET_OS_TVOS)
    [eaglView setMultipleTouchEnabled:NO];
#endif

    // Set EAGLView as view of RootViewController
    self.view = eaglView;
}

That's been the case since Cocos2d-x, and I'm not sure why it was set to NO by default in the template code.

NgVThangBz commented 1 year ago

I'm not sure about this, but if possible you should fix it a bit

rh101 commented 1 year ago

@halx99 Should the iOS project template code be change to enable multi-touch by default?

halx99 commented 1 year ago

@halx99 Should the iOS project template code be change to enable multi-touch by default?

shoud be, do it

halx99 commented 1 year ago

done by https://github.com/axmolengine/axmol/commit/b07cbc5255ae8bb08e6289e87397cc4985eb2569