jason white
jason white

Reputation: 711

callback function of this menu button in javascript

It's defined here

var CMenu = cc.Sprite.extend({

onClickCallback: null,

onClick: function (callback) {
    this.onClickCallback = callback;
},
handleTouches: function (touch, evt) {
    (this.hovered && this.onClickCallback) && this.onClickCallback();});

It's being called here

backMenu.onClick(function () {
    window.location.href = "http://www.test.com";
});

is this.onClickCallback = this.onClickCallback()?

Upvotes: 0

Views: 89

Answers (1)

Sidharth Mudgal
Sidharth Mudgal

Reputation: 4264

this.onClickCallback simply refers to the property onClickCallback of the this object. This will give you the function itself. On the other hand this.onClickCallback() executes that property considering it as a function and will return its result.

So this.onClickCallback is not the same as this.onClickCallback()

Upvotes: 1

Related Questions