fixed some errors for iphone platform

This commit is contained in:
minggo 2011-01-07 10:25:32 +08:00
parent 99dd33f94a
commit a391c8ef99
9 changed files with 280 additions and 53 deletions

View File

@ -286,7 +286,7 @@ void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView)
m_pobOpenGLView = pobOpenGLView; m_pobOpenGLView = pobOpenGLView;
// set size // set size
m_obWinSizeInPoints = CCNSSizeToCGSize(m_pobOpenGLView->getSize()); m_obWinSizeInPoints = m_pobOpenGLView->getSize();
m_obWinSizeInPixels = CGSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, m_obWinSizeInPoints.height * m_fContentScaleFactor); m_obWinSizeInPixels = CGSizeMake(m_obWinSizeInPoints.width * m_fContentScaleFactor, m_obWinSizeInPoints.height * m_fContentScaleFactor);
setGLDefaultValues(); setGLDefaultValues();
@ -828,7 +828,7 @@ bool CCDirector::enableRetinaDisplay(bool enabled)
// if ([[UIScreen mainScreen] scale] == 1.0) // if ([[UIScreen mainScreen] scale] == 1.0)
// return NO; // return NO;
float newScale = enabled ? 2 : 1; float newScale = (float)(enabled ? 2 : 1);
setContentScaleFactor(newScale); setContentScaleFactor(newScale);
return true; return true;

View File

@ -25,58 +25,14 @@ THE SOFTWARE.
#ifndef __PLATFOMR_CCNS_H__ #ifndef __PLATFOMR_CCNS_H__
#define __PLATFOMR_CCNS_H__ #define __PLATFOMR_CCNS_H__
#include "config_platform.h"
#ifdef CCX_PLATFORM_IPHONE
#include <Availability.h>
//#include <Foundation/Foundation.h>
#define CCRectFromString(__r__) CGRectFromString(__r__)
#define CCPointFromString(__p__) CGPointFromString(__p__)
#define CCSizeFromString(__s__) CGSizeFromString(__s__)
#define CCNSSizeToCGSize
#define CCNSRectToCGRect
#define CCNSPointToCGPoint
#define CCTextAlignment UITextAlignment
#define CCTextAlignmentCenter UITextAlignmentCenter
#define CCTextAlignmentLeft UITextAlignmentLeft
#define CCTextAlignmentRight UITextAlignmentRight
#elif defined(CCX_PLATFORM_MAC)
#include <Availability.h>
#include <Foundation/Foundation.h>
#define CCRectFromString(__r__) NSRectToCGRect( NSRectFromString(__r__) )
#define CCPointFromString(__p__) NSPointToCGPoint( NSPointFromString(__p__) )
#define CCSizeFromString(__s__) NSSizeToCGSize( NSSizeFromString(__s__) )
#define CCNSSizeToCGSize NSSizeToCGSize
#define CCNSRectToCGRect NSRectToCGRect
#define CCNSPointToCGPoint NSPointToCGPoint
#define CCTextAlignment NSTextAlignment
#define CCTextAlignmentCenter NSCenterTextAlignment
#define CCTextAlignmentLeft NSLeftTextAlignment
#define CCTextAlignmentRight NSRightTextAlignment
#else
/// @todo
#include "CGGeometry.h" #include "CGGeometry.h"
#define CCRectFromString(__r__) CGRectZero namespace cocos2d
#define CCPointFromString(__p__) CGPointZero {
#define CCSizeFromString(__s__) CGSizeZero CGRect CCRectFromString(const char* pszContent);
#define CCNSSizeToCGSize CGPoint CCPointFromString(const char* pszContent);
#define CCNSRectToCGRect CGSize CCSizeFromString(const char* pszContent);
#define CCNSPointToCGPoint }
#define CCTextAlignment 0
#define CCTextAlignmentCenter 0
#define CCTextAlignmentLeft 0
#define CCTextAlignmentRight 0
#endif
#endif // __PLATFOMR_CCNS_H__ #endif // __PLATFOMR_CCNS_H__

View File

@ -0,0 +1,43 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCNS.h"
///@todo implement the functions
namespace cocos2d
{
CGRect CCRectFromString(const char* pszContent)
{
return CGRectZero;
}
CGPoint CCPointFromString(const char* pszContent)
{
return CGPointZero;
}
CGSize CCSizeFromString(const char* pszContent)
{
return CGSizeZero;
}
}

View File

@ -0,0 +1,69 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCNS.h"
#import <Availability.h>
#import <Foundation/Foundation.h>
static cocos2d::CGRect static_CCRectFromString(const char* pszContent)
{
CGRect rect = CGRectFromString([NSString stringWithUTF8String: pszContent]);
cocos2d::CGRect ret(rect.x, rect.y, rect.width, rect.height);
return ret;
}
static cocos2d::CGPoint static_CCPointFromString(const char* pszContent)
{
CGPoint point = CGPointFromString([NSString stringWithUTF8String: pszContent]);
cocos2d::CGPoint ret(point.x, point.y);
return ret;
}
static cocos2d::CGSize static_CCSizeFromString(const char* pszContent)
{
CGSize size = CGSizeFromString([NSString stringWithUTF8String: pszContent]);
cocos2d::CGSize ret(size.width, size.height);
return ret;
}
///@todo implement the functions
namespace cocos2d
{
CGRect CCRectFromString(const char* pszContent)
{
return static_CCRectFromString(pszContent);
}
CGPoint CCPointFromString(const char* pszContent)
{
return static_CCPointFromString(pszContent);
}
CGSize CCSizeFromString(const char* pszContent)
{
return static_CCSizeFromString(pszContent);
}
}

View File

@ -286,7 +286,7 @@ void CCDirector::setOpenGLView(CC_GLVIEW *pobOpenGLView)
// set size // set size
m_obWinSizeInPixels = m_obWinSizeInPoints = CCNSSizeToCGSize([pobOpenGLView bounds].size); m_obWinSizeInPixels = m_obWinSizeInPoints = NSSizeToCGSize([pobOpenGLView bounds].size);
setGLDefaultValues(); setGLDefaultValues();

View File

@ -0,0 +1,69 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCNS.h"
#import <Availability.h>
#import <Foundation/Foundation.h>
static cocos2d::CGRect static_CCRectFromString(const char* pszContent)
{
CGRect rect = NSRectToCGRect(NSRectFromString([NSString stringWithUTF8String: pszContent]));
cocos2d::CGRect ret(rect.x, rect.y, rect.width, rect.height);
return ret;
}
static cocos2d::CGPoint static_CCPointFromString(const char* pszContent)
{
CGPoint point = NSPointToCGPoint(NSPointFromString([NSString stringWithUTF8String: pszContent]));
cocos2d::CGPoint ret(point.x, point.y);
return ret;
}
static cocos2d::CGSize static_CCSizeFromString(const char* pszContent)
{
CGSize size = NSSizeToCGSize(NSSizeFromString([NSString stringWithUTF8String: pszContent]));
cocos2d::CGSize ret(size.width, size.height);
return ret;
}
///@todo implement the functions
namespace cocos2d
{
CGRect CCRectFromString(const char* pszContent)
{
return static_CCRectFromString(pszContent);
}
CGPoint CCPointFromString(const char* pszContent)
{
return static_CCPointFromString(pszContent);
}
CGSize CCSizeFromString(const char* pszContent)
{
return static_CCSizeFromString(pszContent);
}
}

View File

@ -0,0 +1,43 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCNS.h"
///@todo implement the functions
namespace cocos2d
{
CGRect CCRectFromString(const char* pszContent)
{
return CGRectZero;
}
CGPoint CCPointFromString(const char* pszContent)
{
return CGPointZero;
}
CGSize CCSizeFromString(const char* pszContent)
{
return CGSizeZero;
}
}

View File

@ -0,0 +1,43 @@
/****************************************************************************
Copyright (c) 2010 cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#include "platform/CCNS.h"
///@todo implement the functions
namespace cocos2d
{
CGRect CCRectFromString(const char* pszContent)
{
return CGRectZero;
}
CGPoint CCPointFromString(const char* pszContent)
{
return CGPointZero;
}
CGSize CCSizeFromString(const char* pszContent)
{
return CGSizeZero;
}
}

View File

@ -1011,6 +1011,10 @@
<Filter <Filter
Name="uphone" Name="uphone"
> >
<File
RelativePath="..\platform\uphone\CCNS_uphone.cpp"
>
</File>
<File <File
RelativePath="..\platform\uphone\CCTime.cpp" RelativePath="..\platform\uphone\CCTime.cpp"
> >