Kinetic Scrolling Plugin for Phaser Framework
The vertical and horizontal scrolling is a very useful feature in the games for example to display a section of levels and with this plugin you can simulate the scrolling within a canvas element of HTML5... so check this awesome plugin for Phaser Framework!
Kinetic scrolling based on http://ariya.ofilabs.com/2013/11/javascript-kinetic-scrolling-part-2.html
Download the Plugin
Install via bower
bower i phaser-kinetic-scrolling-plugin --save
Install via npm
npm i phaser-kinetic-scrolling-plugin --save
Load the Plugin
thisgamekineticScrolling = thisgameplugins;
Change Default Settings of the Plugin - It isn't necessary, default is horizontal
thisgamekineticScrolling;
Start the Plugin
thisgamekineticScrollingstart;
Stop the Plugin
thisgamekineticScrolling;
Full Example
var game = 1024 768 PhaserAUTO '' { //Load the plugin thisgamekineticScrolling = thisgameplugins; //If you want change the default configuration before start the plugin } { //Starts the plugin thisgamekineticScrollingstart; //If you want change the default configuration after start the plugin thisrectangles = ; var initX = 50; for var i = 0; i < 26; i++ thisrectangles; thisindex = thisgameaddtextinitX + 125 thisgameworldcenterY i + 1 font: 'bold 150px Arial' align: "center" ; thisindexanchor; initX += 300; //Changing the world width thisgameworld; } { var sprite = thisgameadd; sprite; spritebounds = 0 0 w h; sprite; return sprite; };
Examples
The repository has some examples of the plugin, to run the examples created by the community execute the command gulp examples
from the terminal:
- Horizontal scrolling
- Horizontal scrolling with scrollbar
- Horizontal scrolling and pressing events
- Horizontal and Vertical scrolling (Mouse wheel too)
- onUpdate callback to track delta
Collaborators
Nicholls | Daniel | Vitaliy | Chris Wright | Daaaabeen |
Other Projects
Supporting
I believe in Unicorns 🦄 Support me, if you do too.
Happy scrolling
Made with <3