关于Action动作

1.移动 To是移动到指定位置 , By是以自己为中心向设置的x,y移动 :

<code class="hljs avrasm has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;">var moveTo = cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.moveTo</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>, cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.p</span>(cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.winSize</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.width</span>, cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.winSize</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.height</span>>><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>))
var moveBy = cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.moveBy</span>(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>, cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.p</span>(cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.winSize</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.width</span>, cc<span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.winSize</span><span class="hljs-preprocessor" style="color: rgb(68, 68, 68); box-sizing: border-box;">.height</span>>><span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">1</span>)) </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

2.旋转 To是旋转到指定角度,会走捷径 , By是顺时针旋转指定角度 (顺时针与逆时针取决于角度正负) :

<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">var</span> rotateTo =  cc.rotateTo(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">270</span>)
<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">var</span> rotateBy =  cc.rotateBy(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">2</span>, <span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">270</span>) </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

3.渐影 fadeout 是渐渐消失opacity(255 - 0), fadein 是渐渐显示opacity(0 - 255) :

<code class="hljs cs has-numbering" style="display: block; padding: 0px; color: inherit; box-sizing: border-box; font-family: 'Source Code Pro', monospace;font-size:undefined; white-space: pre; border-radius: 0px; word-wrap: normal; background: transparent;"><span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">var</span> fadeout = cc.fadeOut(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>)
<span class="hljs-keyword" style="color: rgb(0, 0, 136); box-sizing: border-box;">var</span> fadein = cc.fadeOut(<span class="hljs-number" style="color: rgb(0, 102, 102); box-sizing: border-box;">0.5</span>) </code><ul class="pre-numbering" style="box-sizing: border-box; position: absolute; width: 50px; top: 0px; left: 0px; margin: 0px; padding: 6px 0px 40px; border-right-width: 1px; border-right-style: solid; border-right-color: rgb(221, 221, 221); list-style: none; text-align: right; background-color: rgb(238, 238, 238);"><li style="box-sizing: border-box; padding: 0px 5px;">1</li><li style="box-sizing: border-box; padding: 0px 5px;">2</li></ul>

运行动作★★★★★: 
node.runAction(cc.sequence(moveTo,cc.delayTime(2) ,moveBy)) 
cc.sequence 创建动作序列 
cc.delayTime(2) 延时时间

移除动画★★★★★: 
node.runAction(cc.sequence(fadeout,cc.delayTime(0.1), cc.callFunc(this._remove, this)))

_remove:function(target){ 
target.removeFromParent(true) 
},

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值