2016-06-15 4 views
0

휠을 이렇게 회전시키고 싶지만, 회전 할 때 부드럽 지 않습니다. 어떻게하면 원활하게 실행할 수 있습니까? Demococos2d-JS 휠 스핀싱을 부드럽게하는 방법

 var audioengine = cc.audioEngine; 
     audioengine.playMusic(res.Wheel_mp3, false); 

     var spinNumber = Math.floor((Math.random()*360) + 0); 
     var angle = spinNumber + 13*360; 
     var action = new cc.RotateBy(18, angle); 

     var ease = new cc.EaseSineOut(action); 

     this.sprite.runAction(ease); 

답변

0

난 항상 일을 할 무승부() 또는 업데이트를() 새로운 클래스가 스프라이트를 확장 만들고 다시. 여기

은 예입니다 상태를 기록하기 위해, 당신은 (현재 속도, 현재의 가속 속도 등) 몇 가지 매개 변수를 저장할 수있는 속도를 계산하기 위해

var Wheel = Sprite.extend({ 
    ctor and other function : ... 
    draw : function(){ 
    this._super(); 

    var speed = this. calculate Speed(); 
    var rotation = this.getRotation(); 
    var neoRotation = (rotation+speed)%360; 
    this.setRotation(neoRotation) 
    }, 

    caculateSpeed : function(){ 
    // some function that calculate the speed to simulate acceleration and deceleration. 
    // return 0 means not rotate. 
    return speed. 
    } 
}) 

.