为什么不能在按钮中调用函数?移相器

时间:2015-03-03 05:09:15

标签: function timer intervals phaser-framework

我无法使用启动功能,我该怎么办?我的问题是什么?我希望每个人都帮助我:)。感谢您提前帮助!

var diff,
        increase_end_angle = 0,
        start_angle = 1.5 * Math.PI,end_angle = 2 * Math.PI,
        startTime = (new Date()).getTime(),
        circleTimer;

    create: function {
        button =  this.game.add.button(0,0,'btnNext', this.start,this);
    },

    circleTimer: function () {
                var graphics = game.add.graphics(0, 0);         
                diff = (new Date()).getTime() - startTime;
                diff = diff / 60000; //60000ms = 60s            
                increase_end_angle = start_angle + end_angle * diff + reduce;                     
                graphics = game.add.bitmapData(80,80);
                graphics.context.fillStyle = '#D24545';
                graphics.context.beginPath();             
                graphics.context.arc(x,y,radius,start_angle,increase_end_angle,false);
                graphics.context.lineTo(x,y);
                graphics.context.fill();       
                graphics.context.closePath();
                game.add.image(13, 8, graphics);
    },

    start: function () {
        circleTimer = setInterval(this.circleTimer, 200);
    },

    update: function() {
       if(diff > 1 ) {
            clearInterval(circleTimer);
       }
    },

1 个答案:

答案 0 :(得分:0)

似乎对我来说工作得很好:http://codepen.io/kozulowski/pen/dPjXvY

您似乎缺少一些变量:我无法看到reduceradiusxy等的声明。