mirror of https://github.com/axmolengine/axmol.git
commit
ea613be58a
|
@ -521,7 +521,7 @@ static BOOL _mixerRateSet = NO;
|
||||||
if (soundId >= bufferTotal) {
|
if (soundId >= bufferTotal) {
|
||||||
//Need to resize the buffers
|
//Need to resize the buffers
|
||||||
int requiredIncrement = CD_BUFFERS_INCREMENT;
|
int requiredIncrement = CD_BUFFERS_INCREMENT;
|
||||||
while (bufferTotal + requiredIncrement < soundId) {
|
while (bufferTotal + requiredIncrement <= soundId) {
|
||||||
requiredIncrement += CD_BUFFERS_INCREMENT;
|
requiredIncrement += CD_BUFFERS_INCREMENT;
|
||||||
}
|
}
|
||||||
CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId);
|
CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId);
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "support/CCPointExtension.h"
|
#include "support/CCPointExtension.h"
|
||||||
#include "CCActionCatmullRom.h"
|
#include "CCActionCatmullRom.h"
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
NS_CC_BEGIN;
|
NS_CC_BEGIN;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -78,6 +80,7 @@ CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone)
|
||||||
}
|
}
|
||||||
|
|
||||||
CCPointArray *points = CCPointArray::arrayWithCapacity(10);
|
CCPointArray *points = CCPointArray::arrayWithCapacity(10);
|
||||||
|
points->retain();
|
||||||
points->setControlPoints(newArray);
|
points->setControlPoints(newArray);
|
||||||
newArray->release();
|
newArray->release();
|
||||||
|
|
||||||
|
@ -91,14 +94,30 @@ CCPointArray::~CCPointArray()
|
||||||
|
|
||||||
CCPointArray::CCPointArray() :m_pControlPoints(NULL){}
|
CCPointArray::CCPointArray() :m_pControlPoints(NULL){}
|
||||||
|
|
||||||
void CCPointArray::addControlPoint(CCPoint &controlPoint)
|
void CCPointArray::addControlPoint(CCPoint controlPoint)
|
||||||
{
|
{
|
||||||
m_pControlPoints->addObject(&controlPoint);
|
// should create a new object of CCPoint
|
||||||
|
// because developer always use this function like this
|
||||||
|
// addControlPoint(ccp(x, y))
|
||||||
|
// passing controlPoint is a temple object
|
||||||
|
// and CCArray::addObject() will retain the passing object, so it
|
||||||
|
// should be an object created in heap
|
||||||
|
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
|
||||||
|
m_pControlPoints->addObject(temp);
|
||||||
|
temp->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index)
|
void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index)
|
||||||
{
|
{
|
||||||
m_pControlPoints->insertObject(&controlPoint, index);
|
// should create a new object of CCPoint
|
||||||
|
// because developer always use this function like this
|
||||||
|
// insertControlPoint(ccp(x, y))
|
||||||
|
// passing controlPoint is a temple object
|
||||||
|
// and CCArray::insertObject() will retain the passing object, so it
|
||||||
|
// should be an object created in heap
|
||||||
|
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
|
||||||
|
m_pControlPoints->insertObject(temp, index);
|
||||||
|
temp->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
CCPoint CCPointArray::getControlPointAtIndex(unsigned int index)
|
CCPoint CCPointArray::getControlPointAtIndex(unsigned int index)
|
||||||
|
@ -111,7 +130,15 @@ CCPoint CCPointArray::getControlPointAtIndex(unsigned int index)
|
||||||
|
|
||||||
void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index)
|
void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index)
|
||||||
{
|
{
|
||||||
m_pControlPoints->replaceObjectAtIndex(index, &controlPoint);
|
// should create a new object of CCPoint
|
||||||
|
// because developer always use this function like this
|
||||||
|
// replaceControlPoint(ccp(x, y))
|
||||||
|
// passing controlPoint is a temple object
|
||||||
|
// and CCArray::insertObject() will retain the passing object, so it
|
||||||
|
// should be an object created in heap
|
||||||
|
CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y);
|
||||||
|
m_pControlPoints->replaceObjectAtIndex(index, temp);
|
||||||
|
temp->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPointArray::removeControlPointAtIndex(unsigned int index)
|
void CCPointArray::removeControlPointAtIndex(unsigned int index)
|
||||||
|
@ -136,7 +163,6 @@ CCPointArray* CCPointArray::reverse()
|
||||||
|
|
||||||
newArray->release();
|
newArray->release();
|
||||||
|
|
||||||
config->autorelease();
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public:
|
||||||
bool initWithCapacity(unsigned int capacity);
|
bool initWithCapacity(unsigned int capacity);
|
||||||
|
|
||||||
/** appends a control point */
|
/** appends a control point */
|
||||||
void addControlPoint(CCPoint &controlPoint);
|
void addControlPoint(CCPoint controlPoint);
|
||||||
|
|
||||||
/** inserts a controlPoint at index */
|
/** inserts a controlPoint at index */
|
||||||
void insertControlPoint(CCPoint &controlPoint, unsigned int index);
|
void insertControlPoint(CCPoint &controlPoint, unsigned int index);
|
||||||
|
|
|
@ -85,7 +85,7 @@ default gl blend src function. Compatible with premultiplied alpha images.
|
||||||
#define CC_NODE_DRAW_SETUP() \
|
#define CC_NODE_DRAW_SETUP() \
|
||||||
do { \
|
do { \
|
||||||
ccGLEnable( m_glServerState ); \
|
ccGLEnable( m_glServerState ); \
|
||||||
CCAssert(getShaderProgram(), "No shader program set for node: %p", this); \
|
CCAssert(getShaderProgram(), "No shader program set for this node"); \
|
||||||
{ \
|
{ \
|
||||||
getShaderProgram()->use(); \
|
getShaderProgram()->use(); \
|
||||||
getShaderProgram()->setUniformForModelViewProjectionMatrix(); \
|
getShaderProgram()->setUniformForModelViewProjectionMatrix(); \
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
b77ecad7976dbe21bb61300c73e06ddbad3a4bd8
|
c16d1dddb12b5a7e7e715f234dfd031657369f96
|
|
@ -90,7 +90,7 @@ void ActionManagerTest::onEnter()
|
||||||
|
|
||||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||||
addChild(label, 1);
|
addChild(label, 1);
|
||||||
label->setPosition( CCPointMake(s.width/2, s.height-50) );
|
label->setPosition(CCPointMake(s.width/2, s.height-50));
|
||||||
|
|
||||||
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionManagerTest::backCallback) );
|
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionManagerTest::backCallback) );
|
||||||
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionManagerTest::restartCallback) );
|
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionManagerTest::restartCallback) );
|
||||||
|
@ -98,10 +98,10 @@ void ActionManagerTest::onEnter()
|
||||||
|
|
||||||
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
||||||
|
|
||||||
menu->setPosition( CCPointZero );
|
menu->setPosition(CCPointZero);
|
||||||
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
|
item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
item2->setPosition( CCPointMake( s.width/2, 30) );
|
item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2));
|
||||||
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
|
item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
|
|
||||||
addChild(menu, 1);
|
addChild(menu, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -617,8 +617,10 @@ EaseSpriteDemo::~EaseSpriteDemo(void)
|
||||||
|
|
||||||
void EaseSpriteDemo::positionForTwo()
|
void EaseSpriteDemo::positionForTwo()
|
||||||
{
|
{
|
||||||
m_grossini->setPosition( CCPointMake( 60, 120 ) );
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
m_tamara->setPosition( CCPointMake( 60, 220) );
|
|
||||||
|
m_grossini->setPosition(CCPointMake(60, s.height*1/5));
|
||||||
|
m_tamara->setPosition(CCPointMake( 60, s.height*4/5));
|
||||||
m_kathia->setIsVisible(false);
|
m_kathia->setIsVisible(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -643,13 +645,13 @@ void EaseSpriteDemo::onEnter()
|
||||||
|
|
||||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
m_grossini->setPosition( CCPointMake(60, 50) );
|
m_grossini->setPosition(CCPointMake(60, s.height*1/5));
|
||||||
m_kathia->setPosition( CCPointMake(60, 150) );
|
m_kathia->setPosition(CCPointMake(60, s.height*2.5f/5));
|
||||||
m_tamara->setPosition( CCPointMake(60, 250) );
|
m_tamara->setPosition(CCPointMake(60, s.height*4/5));
|
||||||
|
|
||||||
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32);
|
||||||
addChild(label);
|
addChild(label);
|
||||||
label->setPosition( CCPointMake(s.width/2, s.height-50) );
|
label->setPosition(CCPointMake(s.width/2, s.height-50));
|
||||||
|
|
||||||
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) );
|
CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) );
|
||||||
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) );
|
CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) );
|
||||||
|
@ -657,10 +659,10 @@ void EaseSpriteDemo::onEnter()
|
||||||
|
|
||||||
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
||||||
|
|
||||||
menu->setPosition( CCPointZero );
|
menu->setPosition(CCPointZero);
|
||||||
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
|
item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
item2->setPosition( CCPointMake( s.width/2, 30) );
|
item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2));
|
||||||
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
|
item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
|
|
||||||
addChild(menu, 1);
|
addChild(menu, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,10 +111,10 @@ void SpriteDemo::onEnter()
|
||||||
CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
|
CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) );
|
||||||
|
|
||||||
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
||||||
menu->setPosition( CCPointZero );
|
menu->setPosition(CCPointZero);
|
||||||
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
|
item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
item2->setPosition( CCPointMake( s.width/2, 30) );
|
item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2));
|
||||||
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
|
item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
addChild(menu, 1);
|
addChild(menu, 1);
|
||||||
|
|
||||||
CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255,0,0,255));
|
CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255,0,0,255));
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "ActionsTest.h"
|
#include "ActionsTest.h"
|
||||||
#include "../testResource.h"
|
#include "../testResource.h"
|
||||||
|
#include "CCActionCatmullRom.h"
|
||||||
|
|
||||||
CCLayer* NextAction();
|
CCLayer* NextAction();
|
||||||
CCLayer* BackAction();
|
CCLayer* BackAction();
|
||||||
|
@ -13,72 +14,79 @@ CCLayer* CreateLayer(int nIndex)
|
||||||
|
|
||||||
switch (nIndex)
|
switch (nIndex)
|
||||||
{
|
{
|
||||||
case ACTION_MANUAL_LAYER:
|
case ACTION_MANUAL_LAYER:
|
||||||
pLayer = new ActionManual(); break;
|
pLayer = new ActionManual(); break;
|
||||||
case ACTION_MOVE_LAYER:
|
case ACTION_MOVE_LAYER:
|
||||||
pLayer = new ActionMove(); break;
|
pLayer = new ActionMove(); break;
|
||||||
case ACTION_SCALE_LAYER:
|
case ACTION_SCALE_LAYER:
|
||||||
pLayer = new ActionScale(); break;
|
pLayer = new ActionScale(); break;
|
||||||
case ACTION_ROTATE_LAYER:
|
case ACTION_ROTATE_LAYER:
|
||||||
pLayer = new ActionRotate(); break;
|
pLayer = new ActionRotate(); break;
|
||||||
case ACTION_SKEW_LAYER:
|
case ACTION_SKEW_LAYER:
|
||||||
pLayer = new ActionSkew(); break;
|
pLayer = new ActionSkew(); break;
|
||||||
case ACTION_SKEWROTATE_LAYER:
|
case ACTION_SKEWROTATE_LAYER:
|
||||||
pLayer = new ActionSkewRotateScale(); break;
|
pLayer = new ActionSkewRotateScale(); break;
|
||||||
case ACTION_JUMP_LAYER:
|
case ACTION_JUMP_LAYER:
|
||||||
pLayer = new ActionJump(); break;
|
pLayer = new ActionJump(); break;
|
||||||
case ACTION_BEZIER_LAYER:
|
case ACTION_BEZIER_LAYER:
|
||||||
pLayer = new ActionBezier(); break;
|
pLayer = new ActionBezier(); break;
|
||||||
case ACTION_BLINK_LAYER:
|
case ACTION_BLINK_LAYER:
|
||||||
pLayer = new ActionBlink(); break;
|
pLayer = new ActionBlink(); break;
|
||||||
case ACTION_FADE_LAYER:
|
case ACTION_FADE_LAYER:
|
||||||
pLayer = new ActionFade(); break;
|
pLayer = new ActionFade(); break;
|
||||||
case ACTION_TINT_LAYER:
|
case ACTION_TINT_LAYER:
|
||||||
pLayer = new ActionTint(); break;
|
pLayer = new ActionTint(); break;
|
||||||
case ACTION_ANIMATE_LAYER:
|
case ACTION_ANIMATE_LAYER:
|
||||||
pLayer = new ActionAnimate(); break;
|
pLayer = new ActionAnimate(); break;
|
||||||
case ACTION_SEQUENCE_LAYER:
|
case ACTION_SEQUENCE_LAYER:
|
||||||
pLayer = new ActionSequence(); break;
|
pLayer = new ActionSequence(); break;
|
||||||
case ACTION_SEQUENCE2_LAYER:
|
case ACTION_SEQUENCE2_LAYER:
|
||||||
pLayer = new ActionSequence2(); break;
|
pLayer = new ActionSequence2(); break;
|
||||||
case ACTION_SPAWN_LAYER:
|
case ACTION_SPAWN_LAYER:
|
||||||
pLayer = new ActionSpawn(); break;
|
pLayer = new ActionSpawn(); break;
|
||||||
case ACTION_REVERSE:
|
case ACTION_REVERSE:
|
||||||
pLayer = new ActionReverse(); break;
|
pLayer = new ActionReverse(); break;
|
||||||
case ACTION_DELAYTIME_LAYER:
|
case ACTION_DELAYTIME_LAYER:
|
||||||
pLayer = new ActionDelayTime(); break;
|
pLayer = new ActionDelayTime(); break;
|
||||||
case ACTION_REPEAT_LAYER:
|
case ACTION_REPEAT_LAYER:
|
||||||
pLayer = new ActionRepeat(); break;
|
pLayer = new ActionRepeat(); break;
|
||||||
case ACTION_REPEATEFOREVER_LAYER:
|
case ACTION_REPEATEFOREVER_LAYER:
|
||||||
pLayer = new ActionRepeatForever(); break;
|
pLayer = new ActionRepeatForever(); break;
|
||||||
case ACTION_ROTATETOREPEATE_LAYER:
|
case ACTION_ROTATETOREPEATE_LAYER:
|
||||||
pLayer = new ActionRotateToRepeat(); break;
|
pLayer = new ActionRotateToRepeat(); break;
|
||||||
case ACTION_ROTATEJERK_LAYER:
|
case ACTION_ROTATEJERK_LAYER:
|
||||||
pLayer = new ActionRotateJerk(); break;
|
pLayer = new ActionRotateJerk(); break;
|
||||||
case ACTION_CALLFUNC_LAYER:
|
case ACTION_CALLFUNC_LAYER:
|
||||||
pLayer = new ActionCallFunc(); break;
|
pLayer = new ActionCallFunc(); break;
|
||||||
case ACTION_CALLFUNCND_LAYER:
|
case ACTION_CALLFUNCND_LAYER:
|
||||||
pLayer = new ActionCallFuncND(); break;
|
pLayer = new ActionCallFuncND(); break;
|
||||||
case ACTION_REVERSESEQUENCE_LAYER:
|
case ACTION_REVERSESEQUENCE_LAYER:
|
||||||
pLayer = new ActionReverseSequence(); break;
|
pLayer = new ActionReverseSequence(); break;
|
||||||
case ACTION_REVERSESEQUENCE2_LAYER:
|
case ACTION_REVERSESEQUENCE2_LAYER:
|
||||||
pLayer = new ActionReverseSequence2(); break;
|
pLayer = new ActionReverseSequence2(); break;
|
||||||
case ACTION_ORBIT_LAYER:
|
case ACTION_ORBIT_LAYER:
|
||||||
pLayer = new ActionOrbit(); break;
|
pLayer = new ActionOrbit(); break;
|
||||||
case ACTION_FLLOW_LAYER:
|
case ACTION_FLLOW_LAYER:
|
||||||
pLayer = new ActionFollow(); break;
|
pLayer = new ActionFollow(); break;
|
||||||
case ACTION_TARGETED_LAYER:
|
case ACTION_TARGETED_LAYER:
|
||||||
pLayer = new ActionTargeted(); break;
|
pLayer = new ActionTargeted(); break;
|
||||||
case ACTION_ISSUE1305_LAYER:
|
case ACTION_ISSUE1305_LAYER:
|
||||||
pLayer = new Issue1305(); break;
|
pLayer = new Issue1305(); break;
|
||||||
case ACTION_ISSUE1305_2_LAYER:
|
case ACTION_ISSUE1305_2_LAYER:
|
||||||
pLayer = new Issue1305_2(); break;
|
pLayer = new Issue1305_2(); break;
|
||||||
case ACTION_ISSUE1288_LAYER:
|
case ACTION_ISSUE1288_LAYER:
|
||||||
pLayer = new Issue1288(); break;
|
pLayer = new Issue1288(); break;
|
||||||
case ACTION_ISSUE1288_2_LAYER:
|
case ACTION_ISSUE1288_2_LAYER:
|
||||||
pLayer = new Issue1288_2(); break;
|
pLayer = new Issue1288_2(); break;
|
||||||
case ACTION_ISSUE1327_LAYER:
|
case ACTION_ISSUE1327_LAYER:
|
||||||
pLayer = new Issue1327(); break;
|
pLayer = new Issue1327(); break;
|
||||||
|
case ACTION_CARDINALSPLINE_LAYER:
|
||||||
|
pLayer = new ActionCardinalSpline(); break;
|
||||||
|
case ACTION_CATMULLROM_LAYER:
|
||||||
|
pLayer = new ActionCatmullRom(); break;
|
||||||
|
case PAUSERESUMEACTIONS_LAYER:
|
||||||
|
pLayer = new PauseResumeActions(); break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -157,9 +165,9 @@ void ActionsDemo::onEnter()
|
||||||
|
|
||||||
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
m_grossini->setPosition( CCPointMake(s.width/2, s.height/3));
|
m_grossini->setPosition(CCPointMake(s.width/2, s.height/3));
|
||||||
m_tamara->setPosition( CCPointMake(s.width/2, 2*s.height/3));
|
m_tamara->setPosition(CCPointMake(s.width/2, 2*s.height/3));
|
||||||
m_kathia->setPosition( CCPointMake(s.width/2, s.height/2));
|
m_kathia->setPosition(CCPointMake(s.width/2, s.height/2));
|
||||||
|
|
||||||
// add title and subtitle
|
// add title and subtitle
|
||||||
std::string str = title();
|
std::string str = title();
|
||||||
|
@ -183,10 +191,10 @@ void ActionsDemo::onEnter()
|
||||||
|
|
||||||
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL);
|
||||||
|
|
||||||
menu->setPosition( CCPointZero );
|
menu->setPosition(CCPointZero);
|
||||||
item1->setPosition( CCPointMake( s.width/2 - 100,30) );
|
item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
item2->setPosition( CCPointMake( s.width/2, 30) );
|
item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2));
|
||||||
item3->setPosition( CCPointMake( s.width/2 + 100,30) );
|
item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2));
|
||||||
|
|
||||||
addChild(menu, 1);
|
addChild(menu, 1);
|
||||||
}
|
}
|
||||||
|
@ -1441,3 +1449,219 @@ void Issue1327::logSprRotation(CCNode* pSender)
|
||||||
CCLog("%f", ((CCSprite*)pSender)->getRotation());
|
CCLog("%f", ((CCSprite*)pSender)->getRotation());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** ActionCatmullRom
|
||||||
|
*/
|
||||||
|
void ActionCatmullRom::onEnter()
|
||||||
|
{
|
||||||
|
ActionsDemo::onEnter();
|
||||||
|
|
||||||
|
this->centerSprites(2);
|
||||||
|
|
||||||
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
|
//
|
||||||
|
// sprite 1 (By)
|
||||||
|
//
|
||||||
|
// startPosition can be any coordinate, but since the movement
|
||||||
|
// is relative to the Catmull Rom curve, it is better to start with (0,0).
|
||||||
|
//
|
||||||
|
|
||||||
|
m_tamara->setPosition(ccp(50, 50));
|
||||||
|
|
||||||
|
CCPointArray *array = CCPointArray::arrayWithCapacity(20);
|
||||||
|
|
||||||
|
array->addControlPoint(ccp(0, 0));
|
||||||
|
array->addControlPoint(ccp(80, 80));
|
||||||
|
array->addControlPoint(ccp(s.width - 80, 80));
|
||||||
|
array->addControlPoint(ccp(s.width - 80, s.height - 80));
|
||||||
|
array->addControlPoint(ccp(80, s.height - 80));
|
||||||
|
array->addControlPoint(ccp(80, 80));
|
||||||
|
array->addControlPoint(ccp(s.width / 2, s.height / 2));
|
||||||
|
|
||||||
|
CCCatmullRomBy *action = CCCatmullRomBy::actionWithDuration(3, array);
|
||||||
|
CCFiniteTimeAction *reverse = action->reverse();
|
||||||
|
|
||||||
|
CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL);
|
||||||
|
|
||||||
|
m_tamara->runAction(seq);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// sprite 2 (To)
|
||||||
|
//
|
||||||
|
// The startPosition is not important here, because it uses a "To" action.
|
||||||
|
// The initial position will be the 1st point of the Catmull Rom path
|
||||||
|
//
|
||||||
|
|
||||||
|
CCPointArray *array2 = CCPointArray::arrayWithCapacity(20);
|
||||||
|
|
||||||
|
array2->addControlPoint(ccp(s.width / 2, 30));
|
||||||
|
array2->addControlPoint(ccp(s.width -80, 30));
|
||||||
|
array2->addControlPoint(ccp(s.width - 80, s.height - 80));
|
||||||
|
array2->addControlPoint(ccp(s.width / 2, s.height - 80));
|
||||||
|
array2->addControlPoint(ccp(s.width / 2, 30));
|
||||||
|
|
||||||
|
CCCatmullRomTo *action2 = CCCatmullRomTo::actionWithDuration(3, array2);
|
||||||
|
CCFiniteTimeAction *reverse2 = action2->reverse();
|
||||||
|
|
||||||
|
CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL);
|
||||||
|
|
||||||
|
m_kathia->runAction(seq2);
|
||||||
|
|
||||||
|
m_pArray1 = array;
|
||||||
|
m_pArray1->retain();
|
||||||
|
m_pArray2 = array2;
|
||||||
|
m_pArray2->retain();
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionCatmullRom::~ActionCatmullRom()
|
||||||
|
{
|
||||||
|
m_pArray1->release();
|
||||||
|
m_pArray2->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionCatmullRom::draw()
|
||||||
|
{
|
||||||
|
ActionsDemo::draw();
|
||||||
|
|
||||||
|
// move to 50,50 since the "by" path will start at 50,50
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLTranslatef(50, 50, 0);
|
||||||
|
ccDrawCatmullRom(m_pArray1, 50);
|
||||||
|
kmGLPopMatrix();
|
||||||
|
|
||||||
|
ccDrawCatmullRom(m_pArray2,50);
|
||||||
|
}
|
||||||
|
|
||||||
|
string ActionCatmullRom::title()
|
||||||
|
{
|
||||||
|
return "CatmullRomBy / CatmullRomTo";
|
||||||
|
}
|
||||||
|
|
||||||
|
string ActionCatmullRom::subtitle()
|
||||||
|
{
|
||||||
|
return "Catmull Rom spline paths. Testing reverse too";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ActionCardinalSpline
|
||||||
|
*/
|
||||||
|
void ActionCardinalSpline::onEnter()
|
||||||
|
{
|
||||||
|
ActionsDemo::onEnter();
|
||||||
|
|
||||||
|
this->centerSprites(2);
|
||||||
|
|
||||||
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
|
CCPointArray *array = CCPointArray::arrayWithCapacity(20);
|
||||||
|
|
||||||
|
array->addControlPoint(ccp(0, 0));
|
||||||
|
array->addControlPoint(ccp(s.width/2-30, 0));
|
||||||
|
array->addControlPoint(ccp(s.width/2-30, s.height-80));
|
||||||
|
array->addControlPoint(ccp(0, s.height-80));
|
||||||
|
array->addControlPoint(ccp(0, 0));
|
||||||
|
|
||||||
|
//
|
||||||
|
// sprite 1 (By)
|
||||||
|
//
|
||||||
|
// Spline with no tension (tension==0)
|
||||||
|
//
|
||||||
|
|
||||||
|
CCCardinalSplineBy *action = CCCardinalSplineBy::actionWithDuration(3, array, 0);
|
||||||
|
CCActionInterval *reverse = action->reverse();
|
||||||
|
|
||||||
|
CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL);
|
||||||
|
|
||||||
|
m_tamara->setPosition(ccp(50, 50));
|
||||||
|
m_tamara->runAction(seq);
|
||||||
|
|
||||||
|
//
|
||||||
|
// sprite 2 (By)
|
||||||
|
//
|
||||||
|
// Spline with high tension (tension==1)
|
||||||
|
//
|
||||||
|
|
||||||
|
CCCardinalSplineBy *action2 = CCCardinalSplineBy::actionWithDuration(3, array, 1);
|
||||||
|
CCActionInterval *reverse2 = action2->reverse();
|
||||||
|
|
||||||
|
CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL);
|
||||||
|
|
||||||
|
m_kathia->setPosition(ccp(s.width/2, 50));
|
||||||
|
m_kathia->runAction(seq2);
|
||||||
|
|
||||||
|
m_pArray = array;
|
||||||
|
array->retain();
|
||||||
|
}
|
||||||
|
|
||||||
|
ActionCardinalSpline::~ActionCardinalSpline()
|
||||||
|
{
|
||||||
|
m_pArray->release();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ActionCardinalSpline::draw()
|
||||||
|
{
|
||||||
|
ActionsDemo::draw();
|
||||||
|
|
||||||
|
// move to 50,50 since the "by" path will start at 50,50
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLTranslatef(50, 50, 0);
|
||||||
|
ccDrawCardinalSpline(m_pArray, 0, 100);
|
||||||
|
kmGLPopMatrix();
|
||||||
|
|
||||||
|
CCSize s = CCDirector::sharedDirector()->getWinSize();
|
||||||
|
|
||||||
|
kmGLPushMatrix();
|
||||||
|
kmGLTranslatef(s.width/2, 50, 0);
|
||||||
|
ccDrawCardinalSpline(m_pArray, 1, 100);
|
||||||
|
kmGLPopMatrix();
|
||||||
|
}
|
||||||
|
|
||||||
|
string ActionCardinalSpline::title()
|
||||||
|
{
|
||||||
|
return "CardinalSplineBy / CardinalSplineAt";
|
||||||
|
}
|
||||||
|
|
||||||
|
string ActionCardinalSpline::subtitle()
|
||||||
|
{
|
||||||
|
return "Cardinal Spline paths. Testing different tensions for one array";
|
||||||
|
}
|
||||||
|
|
||||||
|
/** PauseResumeActions
|
||||||
|
*/
|
||||||
|
void PauseResumeActions::onEnter()
|
||||||
|
{
|
||||||
|
ActionsDemo::onEnter();
|
||||||
|
|
||||||
|
this->centerSprites(2);
|
||||||
|
|
||||||
|
m_tamara->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360)));
|
||||||
|
m_grossini->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, -360)));
|
||||||
|
m_kathia->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360)));
|
||||||
|
|
||||||
|
this->schedule(schedule_selector(PauseResumeActions::pause), 3, false, 0);
|
||||||
|
this->schedule(schedule_selector(PauseResumeActions::resume), 5, false, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
string PauseResumeActions::title()
|
||||||
|
{
|
||||||
|
return "PauseResumeActions";
|
||||||
|
}
|
||||||
|
|
||||||
|
string PauseResumeActions::subtitle()
|
||||||
|
{
|
||||||
|
return "All actions pause at 3s and resume at 5s";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PauseResumeActions::pause(float dt)
|
||||||
|
{
|
||||||
|
CCLog("Pausing");
|
||||||
|
CCDirector *director = CCDirector::sharedDirector();
|
||||||
|
this->m_pPausedTargets = director->getActionManager()->pauseAlllRunningActions();
|
||||||
|
}
|
||||||
|
|
||||||
|
void PauseResumeActions::resume(float dt)
|
||||||
|
{
|
||||||
|
CCLog("Resuming");
|
||||||
|
CCDirector *director = CCDirector::sharedDirector();
|
||||||
|
director->getActionManager()->resumeTargets(this->m_pPausedTargets);
|
||||||
|
}
|
|
@ -16,6 +16,8 @@ enum
|
||||||
ACTION_SKEW_LAYER,
|
ACTION_SKEW_LAYER,
|
||||||
ACTION_SKEWROTATE_LAYER,
|
ACTION_SKEWROTATE_LAYER,
|
||||||
ACTION_JUMP_LAYER,
|
ACTION_JUMP_LAYER,
|
||||||
|
ACTION_CARDINALSPLINE_LAYER,
|
||||||
|
ACTION_CATMULLROM_LAYER,
|
||||||
ACTION_BEZIER_LAYER,
|
ACTION_BEZIER_LAYER,
|
||||||
ACTION_BLINK_LAYER,
|
ACTION_BLINK_LAYER,
|
||||||
ACTION_FADE_LAYER,
|
ACTION_FADE_LAYER,
|
||||||
|
@ -37,6 +39,7 @@ enum
|
||||||
ACTION_ORBIT_LAYER,
|
ACTION_ORBIT_LAYER,
|
||||||
ACTION_FLLOW_LAYER,
|
ACTION_FLLOW_LAYER,
|
||||||
ACTION_TARGETED_LAYER,
|
ACTION_TARGETED_LAYER,
|
||||||
|
PAUSERESUMEACTIONS_LAYER,
|
||||||
ACTION_ISSUE1305_LAYER,
|
ACTION_ISSUE1305_LAYER,
|
||||||
ACTION_ISSUE1305_2_LAYER,
|
ACTION_ISSUE1305_2_LAYER,
|
||||||
ACTION_ISSUE1288_LAYER,
|
ACTION_ISSUE1288_LAYER,
|
||||||
|
@ -334,4 +337,44 @@ public:
|
||||||
void logSprRotation(CCNode* pSender);
|
void logSprRotation(CCNode* pSender);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class ActionCatmullRom : public ActionsDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~ActionCatmullRom();
|
||||||
|
|
||||||
|
virtual void onEnter();
|
||||||
|
virtual void draw();
|
||||||
|
virtual std::string subtitle();
|
||||||
|
virtual std::string title();
|
||||||
|
private:
|
||||||
|
CCPointArray *m_pArray1;
|
||||||
|
CCPointArray *m_pArray2;
|
||||||
|
};
|
||||||
|
|
||||||
|
class ActionCardinalSpline : public ActionsDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
~ActionCardinalSpline();
|
||||||
|
|
||||||
|
virtual void onEnter();
|
||||||
|
virtual void draw();
|
||||||
|
virtual std::string subtitle();
|
||||||
|
virtual std::string title();
|
||||||
|
private:
|
||||||
|
CCPointArray *m_pArray;
|
||||||
|
};
|
||||||
|
|
||||||
|
class PauseResumeActions : public ActionsDemo
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void onEnter();
|
||||||
|
virtual std::string subtitle();
|
||||||
|
virtual std::string title();
|
||||||
|
|
||||||
|
void pause(float dt);
|
||||||
|
void resume(float dt);
|
||||||
|
private:
|
||||||
|
CCSet *m_pPausedTargets;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue