在Enchant JS框架中创建一个循环运动的精灵



我正在使用enchanted .js框架来创建游戏。我无法为我的精灵创造圆周运动。有人知道怎么做吗?

《A Quick Look Into The Math Of Animations With JavaScript》一文解释了圆周运动背后的很多三角函数

  • http://www.smashingmagazine.com/2011/10/quick-look-math-animations-javascript/

@ lester32在这个JSfiddle的例子http://jsfiddle.net/lewster32/4sj9n927/

    var update = function() 
    {
        var period = game.time.now * 0.001;
        var radius = 60;
        square.x = game.world.centerX + Math.cos(period) * radius;
        square.y = game.world.centerY + Math.sin(period) * radius;
    }
  • http://www.html5gamedevs.com/topic/8529-constant-circular-motion/

相关内容

最新更新