//ccmoveby
建立一個移動的動作
//參數1:移動到目标坐标所需的時間
//參數2:目标坐标
//支援reverse
可以擷取其反向動作
//ccmoveto
一樣的
//ccactioninterval * moveby = ccmoveby::create(5,ccp(300, 100));
//ccactioninterval * actionmoveback= moveby->reverse();
//sp->runaction(actionmoveback);
//ccscaleto
作用:建立一個縮放的動作
//參數1:達到縮放大小所需的時間
//參數2
:縮放的比例
//ccactioninterval * scaleto = ccscaleto ::create(2, 2);
//sp->runaction(scaleto);
//ccscaleby
作用:建立一個縮放的動作
//參數1:達到縮放大小的所需時間
//參數2:縮放比例
//ccactioninterval * scaleby = ccscaleby::create(2, 2);
//ccactioninterval * actionbyback = scaleby->reverse();
//sp->runaction(actionbyback);
//ccrotateto作用建立一個旋轉的動作
//參數1:旋轉的時間
//參數2:旋轉餓角度
0 - 360
//ccactioninterval * rotateto = ccrotateto::create(2, 90);
//sp->runaction(rotateto);
//ccskewto作用建立一個傾斜的動作
//參數1:傾斜到特定角度所需的時間
//參數2:x軸的傾斜角度
//參數3:y軸的傾斜角度
//ccactioninterval * skewto = ccskewto::create(2, 10, 10);
//sp->runaction(skewto);
//ccjumpto
作用:建立一個跳的動作
//參數1:跳到目标動作位子的所需時間
//參數2:目标位置
//參數3:跳的高度
//參數4跳到目标位置的次數
//ccactioninterval* jumpto = ccjumpto ::create(2, ccp(300, 200), 50, 4 );
//sp->runaction(jumpto);
//ccjumpby作用:建立一個跳的動作
//這個支援方向動作reverse
//ccactioninterval * jumpby = ccjumpby ::create(3, ccp(300, 200), 50, 4);
//ccactioninterval * ac= jumpby->reverse();
//sp->runaction(ac);
//ccbezier
//ccbezierconfig結構體
//ccbezierconfig beziercon;
//beziercon.controlpoint_1=ccpointmake(200, 150);//控制點1
//beziercon.controlpoint_2=ccpointmake(200, 160);//控制點2
//beziercon.endposition =ccpointmake(340, 100);//
結束位置
// ccbezierto
//
建立一個貝塞爾曲線運動的動作
參數1:貝塞爾曲線運動的時間
參數2
:ccbezierconfig結構體
ccactioninterval * action = ccbezierto::create(2, beziercon);
ccactioninterval * action = ccbezierby::create(3, beziercon);//支援反向
ccactioninterval * action1 = action->reverse();
sp->runaction(action1);
ccfadein
作用:建立一個漸變出現的動作
參數是時間
ccactioninterval * fadein = ccfadein::create(2);
sp->runaction(fadein);
//ccfadeout
作用:建立一個漸變消失的動作
ccactioninterval * fadeout = ccfadeout::create(2);
sp->runaction(fadeout);
//cctintto作用:建立一個色彩變化的消失動作
參數1:色彩變化的動作
:紅色分量
參數3:藍色分量
ccactioninterval * tinto = cctintto ::create(3, 255, 255, 0);
sp->runaction(tinto);
cctintby
作用:建立一個色彩變化的出現動作
參數3:藍色分量
但是家了reverse就是
反向的
ccactioninterval * tintby = cctintby::create(3, 0, 255, 255);
ccactioninterval * tintby1 = tintby->reverse();
sp->runaction(tintby1);
ccblink
作用 :建立一額閃爍的動作
參數1:閃爍完成的時間
參數2:閃爍的次數
ccactioninterval * blink = ccblink ::create(3, 10);
sp->runaction(blink);
ccdelaytime
建立一個延遲的動作
參數
延遲的時間
ccactioninterval * delaytime = ccdelaytime::create(3);
sp->runaction(delaytime);
ccorbitcamera
作用:建立一個球面坐标軌迹進行旋轉的動作
參數1
:
旋轉軌迹的時間
:起始半徑
參數3:半徑差
參數4:起始z角
參數5:旋轉z角的差
參數6:起始x角
參數7:旋轉x角的差
//
ccactioninterval * orbitcamera = ccorbitcamera::create(3, 10, 0, 45, 180, 90, 0);
sp->runaction(orbitcamera);
cccardinalspline
作用:建立數組
點的數組
ccpointarray * array = ccpointarray::create(20);
array->addcontrolpoint(ccp(0,0));
array->addcontrolpoint(ccp(210,0));
array->addcontrolpoint(ccp(210,240));
array->addcontrolpoint(ccp(0,160));
cccardinalsplineto
作用:建立一個樣條曲線軌迹的動作
參數1:完成軌迹所需的時間
參數2:控制點的坐标數組
拟合度
其值= 0
路徑最柔和
ccactioninterval * cardinalsplineto=cccardinalsplineto::create(3, array, 0);
//
sp->runaction(cardinalsplineto);
//cccardinalsplineby
ccactioninterval * cardinalsplineby = cccardinalsplineby::create(3, array, 0);
sp->runaction(cardinalsplineby);
cccatmullromto cccatmullromby
作用:建立一個樣條插值軌迹
參數1:完成軌迹的時間
參數2:控制點的數組坐标
ccactioninterval * catmullromto = cccatmullromto::create(3, array);
sp->runaction(catmullromto);
ccfollow
作用:建立一個跟随動作
參數1:跟随的目标對象
跟随範圍,離開範圍就不再跟随
//建立一個參照物spt
ccsprite * spt = ccsprite::create("icon.png");
spt->setposition(ccp(420,40));
addchild(spt);
sp->runaction(ccmoveto::create(3, ccp(940,sp->getpositiony())));
ccfollow * follow = ccfollow::create(sp,ccrectmake(0, 0, 960, 320));
this-> runaction(follow);
cceasebouncein 目标動作
ccactioninterval* move = ccmoveto::create(3, ccp(300, sp->getpositiony()));
讓目标動作緩慢開始
參數:目标動作
ccactioninterval * easebouncein = cceasebouncein::create(move);
sp->runaction(easebouncein);
//cceasebounceout作用:讓目标動作賦予反彈力,且以目标動作結束位子開始反彈
參數目标動作
ccactioninterval * easebounceout = cceasebounceout ::create(move);
sp->runaction(easebounceout);
//cceasebounceinout
//作用:讓目标動作賦予反彈力,且以目标動作起始與結束位子開始反彈
ccactioninterval * easebounceinout= cceasebounceinout::create(move);
sp->runaction(easebounceinout);
cceasebackin
作用:讓目标動作賦予回力
,
且以目标動作起點位置作為回力點
ccactioninterval * easebackin = cceasebackin::create(move);
sp->runaction(easebackin);
cceasebackout
作用:讓目标動作賦予回力
且以目标動作終點位置作為回力點
ccactioninterval *easebackout = cceasebackout::create(move);
sp->runaction(easebackout);
//cceasebackinout
且以目标動作起點和終點位置作為回力點
ccactioninterval * easebackinout = cceasebackinout::create(move);
sp->runaction(easebackinout);
cceaseelasticin
作用:讓目标動作賦予彈性
,且以目标動作起點位子賦予彈性
ccactioninterval * easeelasticin= cceaseelasticin::create(move);
sp->runaction(easeelasticin);
cceaseelasticout
,且以目标動作終點位子賦予彈性
ccactioninterval *easeelasticout = cceaseelasticout::create(move);
sp->runaction(easeelasticout);
cceaseelasticinout
,且以目标動作起點和終點位子賦予彈性
ccactioninterval *easeelasticinout = cceaseelasticout::create(move);
sp->runaction(easeelasticinout);
cceaseexponentialin
ccactioninterval * easeexponentialin= cceaseexponentialin::create(move);
sp->runaction(easeexponentialin);
cceaseexponentialout
讓目标動作緩慢中止
ccactioninterval * easeexponentialin= cceaseexponentialout::create(move);
cceaseexponentialinout
讓目标動作緩慢開始和中止
ccactioninterval * easeexponentialinout= cceaseexponentialinout::create(move);
sp->runaction(easeexponentialinout);
cceaserateaction
作用
讓目标動作設定速率
參數1:目标動作
參數2:速率
ccactioninterval * move = ccmoveto::create(5, ccp(300,sp->getpositiony()));
ccactioninterval * easerateaction = cceaserateaction::create(move, 3);
sp->runaction(easerateaction);
cceasesinein作用:動作由慢到快
ccactioninterval * easesinein = cceasesinein::create(move);
sp->runaction(easesinein);
cceasesineout
作用:動作由快到慢
ccactioninterval * easesineout = cceasesineout::create(move);
sp->runaction(easesineout);
cceasesineinout
作用:動作由慢到快再快到慢
ccactioninterval * easesineinout = cceasesineinout::create(move);
sp->runaction(easesineinout);
ccspeed
作用:讓目标動作運作速度加倍
參數1:目标動作
參數2:倍速
ccactioninterval * move = ccmoveto::create(10, ccp(300,sp->getpositiony()));
ccspeed * speed =ccspeed::create(move, 100);
sp->runaction(speed);
ccspawn
//
作用:讓多個動作同時執行
參數:目标動作的可變參數
ccactioninterval * scale = ccscaleto::create(2, 3);
ccactioninterval * rotate = ccrotateto::create(4, 190);
ccfinitetimeaction * spawn =ccspawn::create(move,scale,rotate,null);
sp->runaction(spawn);
ccsequence
作用:讓多個動作按照前後順序逐一執行
ccactioninterval * move = ccmoveto::create(2, ccp(300, sp->getpositiony()));
ccfinitetimeaction * seq= ccsequence::create(move,scale,null);
sp->runaction(seq);
擴充如果要對目标動作全部進行方向運動,可以使用如下形式操作
ccfinitetimeaction *seq=ccsequence::create(moveby,scaleby,...null);
ccfinitetimeaction * reverseseq = ccsequence::create(seq,seq->reverse(),null)
注意ccsequence中的所有動作都必須支援reverse函數,否則會出現異常
ccactioninterval * move = ccmoveby::create(2, ccp(300, sp->getpositiony()));
ccactioninterval * scale = ccscaleby::create(2, 3);
ccfinitetimeaction * reveseseq = ccsequence::create(seq,seq->reverse(),null);
sp->runaction(reveseseq);
ccrepeat
作用:對目标動作進行重複運動(目标動作可以是ccsequence
,ccspawn)
參數2:重複次數
ccactioninterval * move2 = ccmoveto::create(2, ccp(100,100));
ccfinitetimeaction*seq =ccsequence::create(move,move2,null);
ccfinitetimeaction *repeat = ccrepeat::create(seq, 3);
sp->runaction(repeat);
ccrepeatforever
作用:對目标動作進行永久性的重複運動(目标動作可以是ccsequence
ccactioninterval * move = ccmoveto::create(1, ccp(300, sp->getpositiony()));
ccactioninterval * move1 = ccmoveto::create(1, ccp(100,100));
ccfinitetimeaction* seq = ccsequence::create(move,move1,null);
ccactioninterval * repeatforever =ccrepeatforever::create((ccactioninterval* )seq);
sp->runaction(repeatforever);
cccallfunc
作用:建立一個回調動作(調用不帶參數的回調方法);
參數2:目标回調函數
cccallfunc * funcall= cccallfunc::create(this, callfunc_selector(helloworld::callbackc));
ccfinitetimeaction * seq = ccsequence::create(move,funcall,null);
//cccallfuncn
//作用:建立一個回調動作(調用
帶一個參數的回調方法);
//參數1:目标動作
//參數2:目标回調函數
//ccactioninterval * move = ccmoveto::create(1, ccp(300, sp->getpositiony()));
// cccallfuncn * funcall= cccallfuncn::create(this, callfuncn_selector(helloworld::callbackn));
cccallfuncnd
作用:建立一個回調動作(調用
帶兩個參數的回調方法);
cccallfuncnd * funcall= cccallfuncnd::create(this, callfuncnd_selector(helloworld::callbacknd)
,(void*)0xbebabeba);
return true;
}