phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.19k stars 7.1k forks source link

container setInteractive add callback default #3622

Closed poasher closed 6 years ago

poasher commented 6 years ago

callback is marked as an optional parameter Typescipt setInteractive(shape?: any, callback?: HitAreaCallback, dropZone?: boolean): Phaser.GameObjects.GameObject;

let shape = new Phaser.Geom.Rectangle(0, 0, this.image.width, this.image.height);
this.setInteractive(shape);

input.hitAreaCallback is not a function at InputManager.pointWithinHitArea at InputManager.hitTest at InputPlugin.hitTestPointer

photonstorm commented 6 years ago

It's optional if you don't specify the shape. If you do, it's not optional. There's no way to reflect both variations in just the data-types / defs.

photonstorm commented 6 years ago

Docs updated to reflect the requirement.

clickblipclick commented 6 years ago

@photonstorm Just for my own understanding - why do you need a callback if you provide a shape? Should I be doing anything in the callback?

Edit: Nevermind - I understand from here: https://phaser.io/phaser3/devlog/120