Comments (10)
Just submitted a PR (#19) adding the file to the typings
directory along with a README telling people how to install using typings. Typings isn't the most up-to-date way to do TypeScript definitions, so ideally you'd have an addition to the DefinitelyTyped repository. Instructions for how to do this are here: https://github.com/DefinitelyTyped/DefinitelyTyped.
Note that I haven't really been able to test this - it's intended as an initial push so that anyone who's using TypeScript can improve and/or fix this as needed. Unfortunately this isn't something I've got time to do at the moment.
from phaser-kinetic-scrolling-plugin.
Hello!
If needed, I wrote a quick TS Typings file for the plugin:
declare module Phaser {
module Plugin {
export class KineticScrolling extends Phaser.Plugin {
constructor(game:Phaser.Game, parent:any);
setup(params: any): void;
start();
configure(params: any);
//other methods if needed
}
}
interface Game {
kineticScrolling: Plugin.KineticScrolling;
}
}
declare module 'phaser-kinetic-scrolling-plugin' {
}
(sorry for bad indent)
And then, you juste have to include your JS or require() it for Webpack users.
To be more complete:
- Define all public plugin methods
- Define clearly params: any
Have fun!
from phaser-kinetic-scrolling-plugin.
More detailed typings file for this plugin, with comments copied over from source code:
declare module Phaser {
module Plugin {
/**
* Settings to change behaviour of Kinetic Scrolling plugin.
*/
interface KineticScrollingSettings {
/**
* Enable or disable the kinematic motion.
*/
kineticMovement?: boolean;
/**
* The rate of deceleration for the scrolling.
*/
timeConstantScroll?: number;
/**
* Enable or disable the horizontal scrolling.
*/
horizontalScroll?: boolean;
/**
* Enable or disable the vertical scrolling.
*/
verticalScroll?: boolean;
/**
* Enable or disable the horizontal scrolling with the mouse wheel.
*/
horizontalWheel?: boolean;
/**
* Enable or disable the vertical scrolling with the mouse wheel.
*/
verticalWheel?: boolean;
/**
* Delta increment of the mouse wheel.
*/
deltaWheel?: number;
}
/**
* Kinetic Scrolling is a Phaser plugin that allows vertical and horizontal scrolling with kinetic motion.
* It works with the Phaser.Camera
*/
export class KineticScrolling extends Phaser.Plugin {
/**
* @param game The Game object is the instance of the game, where the magic happens.
* @param parent The object that owns this plugin, usually Phaser.PluginManager.
*/
constructor(game: Phaser.Game, parent: Phaser.PluginManager);
/**
* Start the Plugin.
*/
public start(): void;
/**
* Stop the Plugin.
*/
public stop(): void;
/**
* Change Default Settings of the plugin
* @param options Object that contain properties to change the behavior of the plugin.
*/
public configure(options: KineticScrollingSettings): void;
}
}
interface Game {
/**
* Instance of the plugin that handles kinetic scrolling with mouse, dragging or mouse wheel.
*/
kineticScrolling: Plugin.KineticScrolling;
}
}
declare module "phaser-kinetic-scrolling-plugin" { }
from phaser-kinetic-scrolling-plugin.
Check the examples! You need to load the plugin into the states 👍
Regards, Nicholls
from phaser-kinetic-scrolling-plugin.
i did not get it to work. i think its because you wrote it in javascript. and im using typescript.
from phaser-kinetic-scrolling-plugin.
I need to do tests with TypeScript.
from phaser-kinetic-scrolling-plugin.
This is not working for me, anybody has a example project with Phaser 2.6 and Typescript?
from phaser-kinetic-scrolling-plugin.
Ohh I need to add the typings file to support TypeScript...
@drewsilcock do you want to be a collaborator of this project and add your example? 👍
Let me know what you think
from phaser-kinetic-scrolling-plugin.
@CyrilleGuimezanes @drewsilcock where is the best place in the repository to have the TypeScript definition files? any example of other plugin?
from phaser-kinetic-scrolling-plugin.
Added, thanks for the help guys!
from phaser-kinetic-scrolling-plugin.
Related Issues (18)
- Publish package to npm HOT 3
- Multidirectional scrolling support HOT 1
- Scrolling large bodies of text within a group HOT 6
- Phaser CE HOT 4
- Looking collaborators!
- is it possible to set up infinite scrolling within a world of a given size? HOT 1
- select element HOT 1
- stop slide effect after mouse click HOT 1
- Destribution with npm is not working HOT 1
- Auto scroll activated HOT 4
- Sprite shifts when game scale is not 1 HOT 1
- Disable body while dragging map around HOT 1
- Phaser 3 version HOT 5
- Stopping plugin in inputDown event cause problem when plugin is started again HOT 1
- When multiple touch point/fingers are used to scroll, it breaks HOT 2
- How to scroll text? HOT 2
- 1.0.3 missing from npm HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phaser-kinetic-scrolling-plugin.