Description

(>= 1.3.0) Force applying an event on the element even if it is invisible. Assign the height and width

In the case of an image, when the user clicks, the event will be triggered if he clicks on an opaque area of ​​the image. By cons, if you use the forceEvent() method, the entire area of the element that will be sensitive to click. The interest is to provide a larger area to click (useful for touch devices) or give clickable transparent areas

Usage

Parameters

  • (optional) {Boolean}

    activate activate all the clickable area (true by default)

Returns

CanvasEngine.Element

Example

Code in ready() method of current scene :

Example 1 :

var el = this.createElement(100, 100);
el.forceEvent();
el.click(function() {
    console.log("foo");
});

Example 2, If the size of the element does not exist, it is the size of the image to be taken :

var el = this.createElement();
el.drawImage("my_img");
el.forceEvent();
el.click(function() {
    console.log("foo");
});

Example 3 :

var el = this.createElement();
el.drawImage("my_img");
el.forceEvent();
el.click(function() {
    this.forceEvent(false);
});

Discussion