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.12k stars 7.1k forks source link

TS definitions, i think sprite.body.* are missing, #857

Closed elgansayer closed 10 years ago

elgansayer commented 10 years ago

Autocorrect when typing sprite.body.* all seem to be blank?

hilts-vaughan commented 10 years ago

Body is defined as an 'any' because the definition depends on which physics engine you're using.

lewster32 commented 10 years ago

This is likely because sprite.body can be one of three different systems, each with their own set of properties and methods.

elgansayer commented 10 years ago

That makes a lot of sense, Would be impossible have them all.

hilts-vaughan commented 10 years ago

They don't follow a uniform interface, so unfortunately not. However! You can always do a type cast to get Intellisense if you wrap your sprite. So if you know you're using Arcade physics, when you go to extend sprite, write an an accessor for body that is just a getter to return a type cased version of the phaser body. Then you get strong typed Intellisense :)

On Thu, May 29, 2014 at 11:50 AM, elgansayer notifications@github.comwrote:

Closed #857 https://github.com/photonstorm/phaser/issues/857.

— Reply to this email directly or view it on GitHubhttps://github.com/photonstorm/phaser/issues/857#event-126045639 .

elgansayer commented 10 years ago

very smart idea of course!, i've just been using the very nice documentation online for now.

Thank you :)