DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

[port iOS -> MAC] Using HD assets #1354

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. on "ccConfig.h" I set CC_IS_RETINA_DISPLAY_SUPPORTED to 1
2. on "ccMacros.h" I set CC_CONTENT_SCALE_FACTOR() to 2
3. my opengl screen size is 960x640 to simulate a retina display
4. director resize mode is set to kCCDirectorResize_AutoScale

What is the expected output? What do you see instead?
Simulation of retina display works 100%, but with only ONE PROBLEM:
- CCMenu is not working. What happens is: CCMenuItems are on the right places, 
but they don't recognize clicks for the HD area/position. They do work for 
their low resolution area/position.

What cocos2d version are you using ?
1.0.0

What iOS / Mac SDK are you using ?
mac 10.6

Debug or Release ?
debug

Which target device / target OS are you using ?
osx 10.6

iOS only: Does this happens on device ? or on the simulator ? or on both ?

Mac only: x86 or i386 ?
both

Please provide any additional information below.

Original issue reported on code.google.com by neves.jhenrique@gmail.com on 27 Mar 2012 at 6:49

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
since my project has targets to iOS and MAC on the file "ccMacros.h" to modify 
the value for CC_CONTENT_SCALE_FACTOR() I did the following:

[...]
/****************************/
/** RETINA DISPLAY ENABLED **/
/****************************/

#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED)
/** @def CC_CONTENT_SCALE_FACTOR
 On Mac it returns 1;
 On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
 */
#import "Platforms/iOS/CCDirectorIOS.h"
#define CC_CONTENT_SCALE_FACTOR() __ccContentScaleFactor

#elif defined(__MAC_OS_X_VERSION_MAX_ALLOWED)

#define CC_CONTENT_SCALE_FACTOR() 2.0f

#endif

[...]

Original comment by neves.jhenrique@gmail.com on 27 Mar 2012 at 7:02

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 27 Mar 2012 at 7:36

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 27 Mar 2012 at 7:37

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
these modifications on the method I mentioned seemed to work, but I am not sure 
of its correctness, but hey it works :)

-(CCMenuItem *) itemForMouseEvent: (NSEvent *) event
{
    CGPoint location = [(CCDirectorMac*)[CCDirector sharedDirector] convertEventToGL:event];

    CCMenuItem* item;
    CCARRAY_FOREACH(children_, item){
        // ignore invisible and disabled items:  issue #779 , #866
        if ( [item visible] && [item isEnabled] ) {

            //CGPoint local = [item convertToNodeSpace:location];

            CGRect r = [item rect];
                        r = CGRectMake(r.origin.x * 2.0f, r.origin.y * 2.0f, r.size.width * 2.0f, r.size.height * 2.0f);
            //r.origin = CGPointZero;

            if( CGRectContainsPoint( r, location ) )
                return item;
        }
    }
    return nil;
}

Original comment by neves.jhenrique@gmail.com on 27 Mar 2012 at 8:20

GoogleCodeExporter commented 9 years ago
If I change the position of the CCMenu via an CCMoveTo action, the clickeable 
area doesnt move along.

This should help:

r = CGRectMake((r.origin.x   * CC_CONTENT_SCALE_FACTOR()) + 
(item.parent.position.x * CC_CONTENT_SCALE_FACTOR()),
                           (r.origin.y   * CC_CONTENT_SCALE_FACTOR()) + (item.parent.position.y * CC_CONTENT_SCALE_FACTOR()),
                           r.size.width  * CC_CONTENT_SCALE_FACTOR(),
                           r.size.height * CC_CONTENT_SCALE_FACTOR());

Original comment by neves.jhenrique@gmail.com on 27 Mar 2012 at 8:49

GoogleCodeExporter commented 9 years ago

Original comment by ricardoq...@gmail.com on 16 Apr 2012 at 11:05