Quantcast
Channel: Cocos Forums - Latest topics
Viewing all articles
Browse latest Browse all 17117

Scheduler basics

$
0
0

@KraKcz wrote:

Hello, I started to learn Cocos, but I ran into a problem with scheduler, I know it’s probably a simple mistake but I cannot figure it out. It’s not repeating but only runs once.

cc.Class({
    extends: cc.Component,

    properties: {
        rychlost: 0
    },

    // LIFE-CYCLE CALLBACKS:

    start () {
        this.node.runAction(cc.repeatForever(cc.rotateBy(this.rychlost, 360))); //experimenting
         this.component();
    },

    component: function() {
        this.schedule(function() {
            this.component();
            cc.log("Repeat every 2 seconds.") //Here
        }, 2);
    },

    update (dt) {

     },
});

I read docs: http://docs.cocos.com/creator/manual/en/scripting/scheduler.html
But probably I misunderstood the:

First, create a variable named component that refers to a component.

So thank you very much simple repair and some basic example.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 17117


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>