• Stars
    star
    130
  • Rank 269,543 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created almost 9 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kinetic Scrolling plugin for Canvas using Phaser Framework

MIT license Current npm package version Maintenance Downloads Total downloads Follow @jdnichollsc

Kinetic Scrolling Plugin for Phaser Framework

Kinetic Scrolling Plugin

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

NPM

Install via bower

bower i phaser-kinetic-scrolling-plugin --save

Install via npm

npm i phaser-kinetic-scrolling-plugin --save

Load the Plugin

this.game.kineticScrolling = this.game.plugins.add(Phaser.Plugin.KineticScrolling);

Change Default Settings of the Plugin - It isn't necessary, default is horizontal

this.game.kineticScrolling.configure({
    kineticMovement: true,
    timeConstantScroll: 325, //really mimic iOS
    horizontalScroll: true,
    verticalScroll: false,
    horizontalWheel: true,
    verticalWheel: false,
    deltaWheel: 40,
    onUpdate: null //A function to get the delta values if it's required (deltaX, deltaY)
});

Start the Plugin

this.game.kineticScrolling.start();

Stop the Plugin

this.game.kineticScrolling.stop();

Full Example

var game = new Phaser.Game(1024, 768, Phaser.AUTO, '', {
    init: function () {

        //Load the plugin
        this.game.kineticScrolling = this.game.plugins.add(Phaser.Plugin.KineticScrolling);

        //If you want change the default configuration before start the plugin
    },
    create: function () {

        //Starts the plugin
        this.game.kineticScrolling.start();

        //If you want change the default configuration after start the plugin

        this.rectangles = [];

        var initX = 50;

        for (var i = 0; i < 26; i++) {
            this.rectangles.push(this.createRectangle(initX, this.game.world.centerY - 100, 250, 200));
            this.index = this.game.add.text(initX + 125, this.game.world.centerY, i + 1,
                        { font: 'bold 150px Arial', align: "center" });
            this.index.anchor.set(0.5);
            initX += 300;
        }

        //Changing the world width
        this.game.world.setBounds(0, 0, 320 * this.rectangles.length, this.game.height);
    },
    createRectangle: function (x, y, w, h) {
        var sprite = this.game.add.graphics(x, y);
        sprite.beginFill(Phaser.Color.getRandomColor(100, 255), 1);
        sprite.bounds = new PIXI.Rectangle(0, 0, w, h);
        sprite.drawRect(0, 0, w, h);
        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

Other Projects

Contributing ✨

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated ❤️.
You can learn more about how you can contribute to this project in the contribution guide.

Collaborators

jdnichollsc daniel-mf VitaZheltyakov iamchristopher daaaabeen
Nicholls Daniel Vitaliy Chris Wright Daaaabeen

Supporting 🍻

I believe in Unicorns 🦄 Support me, if you do too.

Donate Ethereum, ADA, BNB, SHIBA, USDT, DOGE:

Wallet address

Wallet address: 0x3F9fA8021B43ACe578C2352861Cf335449F33427

Please let us know your contributions! 🙏

License ⚖️

This repository is available under the MIT License.

Happy scrolling 💯

Made with <3

More Repositories

1

react-native-inappbrowser

📱InAppBrowser for React Native (Android & iOS) 🤘
Java
1,266
star
2

RestClient

🦄 A Promise based REST and HTTP client for Unity 🎮
C#
1,214
star
3

awesome-unity

A curated list of awesome Unity games! 🎮
714
star
4

awesome-jsgames

A curated list of awesome JavaScript Games 🎮
445
star
5

TheJobInterviewGuide

A job guide to help developers get through interviews and get amazing jobs!
333
star
6

ion-phaser

A web component to use Phaser Framework with Angular, React, Vue, etc 🎮
TypeScript
248
star
7

animatable-component

Animate once, use Everywhere! 💫
TypeScript
245
star
8

MyAPI

A template to create awesome APIs easily ⚡️
TypeScript
135
star
9

MyApp

A template to create awesome Apps easily ⚡️
TypeScript
75
star
10

nativescript-inappbrowser

📱InAppBrowser for NativeScript (Android & iOS) 🤘
TypeScript
72
star
11

nativescript-ionic-template

📱 🖥 Create Mobile First apps, Web and Native sharing the code with Angular 🎉
TypeScript
69
star
12

cardano-developer

A Cardano Developer Guide
62
star
13

proyecto26.github.io

The Proyecto26 github homepage.
JavaScript
57
star
14

thecryptopurge

A crypto shooter-survival real-time NFT-based game inspired by The Purge 💸
JavaScript
57
star
15

MyBot

🧠 Create chatbots easily with Bot Framework! 🤖
JavaScript
31
star
16

Phaser-Workshop

A workshop to create awesome games with Phaser Framework 🎮
22
star
17

mercadopago-api

API for MercadoPago Checkout
TypeScript
20
star
18

Roxy-Fileman-for-Node.js

Roxy Fileman, upload and manage files with Node.js!
JavaScript
15
star
19

PokeDex-GO

The Best PokéDex for Pokémon Go, created by Pokémon masters! 😺
JavaScript
14
star
20

ion-phaser-ce

A web component to use Phaser Framework CE (Community Edition) with Angular, React, Vue, etc 🎮
TypeScript
11
star
21

use-dictionary

A React useReducer() hook to use dictionaries (keys and values) 🔑
TypeScript
9
star
22

dotnet-documentation

SOLID, DI, N-Tier, Logs, etc with dotnet
9
star
23

react-native-mercado-pago-enterprise

Integrating Mobile Checkout of MercadoPago with React Native to create a payment experience in your applications.
8
star
24

colombia

Departamentos y Municipios de Colombia 🇨🇴
6
star
25

BuyMeNear

Buy Me Near is a revolutionary, meaningful way to fund your creative work.
JavaScript
6
star
26

react-native-animations-demo

Animate with React Native ⏯
JavaScript
6
star
27

web-animations-workshop

Workshop of Web Animations API and Web Components
4
star
28

record-audio-button-enterprise

🔴 A Web Component for Recording Audio with a swipe gesture inspired by WhatsApp (Enterprise) 💼
4
star
29

Xamarin

A summary/template about Xamarin 📱
C#
3
star
30

social-change

Social change through technology, together we are more! 💪
3
star
31

Phaser-Market

Discover & share phaser plugins for your games
CSS
3
star
32

OpenSourceCoin

A cryptocurrency for Open Source Contributors & Developers
2
star
33

stencil-ionic-components

Create StencilJS Components reusing Ionic components
TypeScript
2
star
34

concertx-frontend

Empowering musical artists and fans with immersive concert experiences and trusted transactions. Start bringing your concert ideas to life today!
TypeScript
2
star
35

ionic-background-geolocation

Background Geolocation App using BackgroundLocation and Location ionic plugins
TypeScript
2
star
36

NodeBots

Nodebots (Tessel), IoT and Azure
JavaScript
1
star
37

flutter-inappbrowser

📱InAppBrowser for Flutter (Android & iOS) 🤘
1
star
38

ProjectX

NextJS template with TailwindCSS, etc
1
star