mirror of https://github.com/axmolengine/axmol.git
fixed #283 Add member data m_positionInPixels for some classes.
This commit is contained in:
parent
e3b49d7504
commit
e11ccb50fe
|
@ -362,10 +362,11 @@ namespace cocos2d
|
|||
{
|
||||
if (CCGrid3DAction::initWithSize(gridSize, duration))
|
||||
{
|
||||
m_position = pos;
|
||||
m_position = ccp(-1, -1);
|
||||
setPosition(pos);
|
||||
m_fRadius = r;
|
||||
m_fLensEffect = 0.7f;
|
||||
m_lastPosition = ccp(-1, -1);
|
||||
m_bDirty = YES;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -396,9 +397,20 @@ namespace cocos2d
|
|||
return pCopy;
|
||||
}
|
||||
|
||||
void CCLens3D::setPosition(CGPoint pos)
|
||||
{
|
||||
if( ! CGPoint::CGPointEqualToPoint(pos, m_position) ) {
|
||||
m_position = pos;
|
||||
m_positionInPixels.x = pos.x * CC_CONTENT_SCALE_FACTOR();
|
||||
m_positionInPixels.y = pos.y * CC_CONTENT_SCALE_FACTOR();
|
||||
|
||||
m_bDirty = YES;
|
||||
}
|
||||
}
|
||||
|
||||
void CCLens3D::update(cocos2d::ccTime time)
|
||||
{
|
||||
if (m_position.x != m_lastPosition.x || m_position.y != m_lastPosition.y )
|
||||
if (m_bDirty)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
|
@ -407,7 +419,7 @@ namespace cocos2d
|
|||
for (j = 0; j < m_sGridSize.y + 1; ++j)
|
||||
{
|
||||
ccVertex3F v = originalVertex(ccg(i, j));
|
||||
CGPoint vect = ccpSub(m_position, ccp(v.x, v.y));
|
||||
CGPoint vect = ccpSub(m_positionInPixels, ccp(v.x, v.y));
|
||||
CGFloat r = ccpLength(vect);
|
||||
|
||||
if (r < m_fRadius)
|
||||
|
@ -434,7 +446,7 @@ namespace cocos2d
|
|||
}
|
||||
}
|
||||
|
||||
m_lastPosition = m_position;
|
||||
m_bDirty = NO;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -463,7 +475,7 @@ namespace cocos2d
|
|||
{
|
||||
if (CCGrid3DAction::initWithSize(gridSize, duration))
|
||||
{
|
||||
m_position = pos;
|
||||
setPosition(pos);
|
||||
m_fRadius = r;
|
||||
m_nWaves = wav;
|
||||
m_fAmplitude = amp;
|
||||
|
@ -475,6 +487,13 @@ namespace cocos2d
|
|||
return false;
|
||||
}
|
||||
|
||||
void CCRipple3D::setPosition(CGPoint position)
|
||||
{
|
||||
m_position = position;
|
||||
m_positionInPixels.x = position.x * CC_CONTENT_SCALE_FACTOR();
|
||||
m_positionInPixels.y = position.y * CC_CONTENT_SCALE_FACTOR();
|
||||
}
|
||||
|
||||
NSObject* CCRipple3D::copyWithZone(cocos2d::NSZone *pZone)
|
||||
{
|
||||
NSZone* pNewZone = NULL;
|
||||
|
@ -507,7 +526,7 @@ namespace cocos2d
|
|||
for (j = 0; j < (m_sGridSize.y+1); ++j)
|
||||
{
|
||||
ccVertex3F v = originalVertex(ccg(i, j));
|
||||
CGPoint vect = ccpSub(m_position, ccp(v.x,v.y));
|
||||
CGPoint vect = ccpSub(m_positionInPixels, ccp(v.x,v.y));
|
||||
CGFloat r = ccpLength(vect);
|
||||
|
||||
if (r < m_fRadius)
|
||||
|
@ -784,7 +803,7 @@ namespace cocos2d
|
|||
{
|
||||
if (CCGrid3DAction::initWithSize(gridSize, duration))
|
||||
{
|
||||
m_position = pos;
|
||||
setPosition(pos);
|
||||
m_nTwirls = t;
|
||||
m_fAmplitude = amp;
|
||||
m_fAmplitudeRate = 1.0f;
|
||||
|
@ -795,6 +814,13 @@ namespace cocos2d
|
|||
return false;
|
||||
}
|
||||
|
||||
void CCTwirl::setPosition(CGPoint position)
|
||||
{
|
||||
m_position = position;
|
||||
m_positionInPixels.x = position.x * CC_CONTENT_SCALE_FACTOR();
|
||||
m_positionInPixels.y = position.y * CC_CONTENT_SCALE_FACTOR();
|
||||
}
|
||||
|
||||
NSObject* CCTwirl::copyWithZone(cocos2d::NSZone *pZone)
|
||||
{
|
||||
NSZone* pNewZone = NULL;
|
||||
|
@ -822,7 +848,7 @@ namespace cocos2d
|
|||
void CCTwirl::update(cocos2d::ccTime time)
|
||||
{
|
||||
int i, j;
|
||||
CGPoint c = m_position;
|
||||
CGPoint c = m_positionInPixels;
|
||||
|
||||
for (i = 0; i < (m_sGridSize.x+1); ++i)
|
||||
{
|
||||
|
@ -836,9 +862,9 @@ namespace cocos2d
|
|||
CGFloat amp = 0.1f * m_fAmplitude * m_fAmplitudeRate;
|
||||
CGFloat a = r * cosf( (CGFloat)M_PI/2.0f + time * (CGFloat)M_PI * m_nTwirls * 2 ) * amp;
|
||||
|
||||
CGPoint d;
|
||||
|
||||
d.x = sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x);
|
||||
CGPoint d;
|
||||
|
||||
d.x = sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x);
|
||||
d.y = cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x);
|
||||
|
||||
v.x = c.x + d.x;
|
||||
|
|
|
@ -93,7 +93,7 @@ namespace cocos2d
|
|||
inline void setLensEffect(float fLensEffect) { m_fLensEffect = fLensEffect; }
|
||||
|
||||
inline CGPoint getPosition(void) { return m_position; }
|
||||
inline void setPosition(CGPoint position) { m_position = position; }
|
||||
void setPosition(CGPoint position);
|
||||
|
||||
/** initializes the action with center position, radius, a grid size and duration */
|
||||
bool initWithPosition(CGPoint pos, float r, ccGridSize gridSize, ccTime duration);
|
||||
|
@ -109,7 +109,11 @@ namespace cocos2d
|
|||
float m_fRadius;
|
||||
/** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */
|
||||
float m_fLensEffect;
|
||||
CGPoint m_lastPosition;
|
||||
|
||||
/* @since v0.99.5 */
|
||||
// CGPoint m_lastPosition;
|
||||
CGPoint m_positionInPixels;
|
||||
bool m_bDirty;
|
||||
};
|
||||
|
||||
/** @brief CCRipple3D action */
|
||||
|
@ -119,7 +123,7 @@ namespace cocos2d
|
|||
/** get center position */
|
||||
inline CGPoint getPosition(void) { return m_position; }
|
||||
/** set center position */
|
||||
inline void setPosition(CGPoint position) { m_position = position; }
|
||||
void setPosition(CGPoint position);
|
||||
|
||||
inline float getAmplitude(void) { return m_fAmplitude; }
|
||||
inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }
|
||||
|
@ -144,6 +148,9 @@ namespace cocos2d
|
|||
int m_nWaves;
|
||||
float m_fAmplitude;
|
||||
float m_fAmplitudeRate;
|
||||
|
||||
/*@since v0.99.5*/
|
||||
CGPoint m_positionInPixels;
|
||||
};
|
||||
|
||||
/** @brief CCShaky3D action */
|
||||
|
@ -224,7 +231,7 @@ namespace cocos2d
|
|||
/** get twirl center */
|
||||
inline CGPoint getPosition(void) { return m_position; }
|
||||
/** set twirl center */
|
||||
inline void setPosition(CGPoint position) { m_position = position; }
|
||||
void setPosition(CGPoint position);
|
||||
|
||||
inline float getAmplitude(void) { return m_fAmplitude; }
|
||||
inline void setAmplitude(float fAmplitude) { m_fAmplitude = fAmplitude; }
|
||||
|
@ -248,6 +255,9 @@ namespace cocos2d
|
|||
int m_nTwirls;
|
||||
float m_fAmplitude;
|
||||
float m_fAmplitudeRate;
|
||||
|
||||
/*@since v0.99.5 */
|
||||
CGPoint m_positionInPixels;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -203,5 +203,48 @@ default gl blend src function. Compatible with premultiplied alpha images.
|
|||
TypeName(const TypeName&);\
|
||||
void operator=(const TypeName&)
|
||||
|
||||
/**
|
||||
@since v0.99.5
|
||||
@todo upto-0.99.5 check the code for retina
|
||||
*/
|
||||
#if CC_IS_RETINA_DISPLAY_SUPPORTED
|
||||
|
||||
/****************************/
|
||||
/** RETINA DISPLAY ENABLED **/
|
||||
/****************************/
|
||||
|
||||
/** @def CC_CONTENT_SCALE_FACTOR
|
||||
On Mac it returns 1;
|
||||
On iPhone it returns 2 if RetinaDisplay is On. Otherwise it returns 1
|
||||
*/
|
||||
#include "Platforms/iOS/CCDirectorIOS.h"
|
||||
#define CC_CONTENT_SCALE_FACTOR() __ccContentScaleFactor
|
||||
|
||||
|
||||
/** @def CC_RECT_PIXELS_TO_POINTS
|
||||
Converts a rect in pixels to points
|
||||
*/
|
||||
#define CC_RECT_PIXELS_TO_POINTS(__pixels__) \
|
||||
CGRectMake( (__pixels__).origin.x / CC_CONTENT_SCALE_FACTOR(), (__pixels__).origin.y / CC_CONTENT_SCALE_FACTOR(), \
|
||||
(__pixels__).size.width / CC_CONTENT_SCALE_FACTOR(), (__pixels__).size.height / CC_CONTENT_SCALE_FACTOR() )
|
||||
|
||||
/** @def CC_RECT_POINTS_TO_PIXELS
|
||||
Converts a rect in points to pixels
|
||||
*/
|
||||
#define CC_RECT_POINTS_TO_PIXELS(__points__) \
|
||||
CGRectMake( (__points__).origin.x * CC_CONTENT_SCALE_FACTOR(), (__points__).origin.y * CC_CONTENT_SCALE_FACTOR(), \
|
||||
(__points__).size.width * CC_CONTENT_SCALE_FACTOR(), (__points__).size.height * CC_CONTENT_SCALE_FACTOR() )
|
||||
|
||||
#else // retina disabled
|
||||
|
||||
/*****************************/
|
||||
/** RETINA DISPLAY DISABLED **/
|
||||
/*****************************/
|
||||
|
||||
#define CC_CONTENT_SCALE_FACTOR() 1
|
||||
#define CC_RECT_PIXELS_TO_POINTS(__pixels__) __pixels__
|
||||
#define CC_RECT_POINTS_TO_PIXELS(__points__) __points__
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __CCMACROS_H__
|
||||
|
|
Loading…
Reference in New Issue