npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pixelburp/phaser3-drag-select

v1.2.6

Published

Phaser3 Mouse Drag Select plugin

Downloads

2

Readme

Phaser 3 Drag Select Plugin

How to install:

Add it to your project as a normal dependency:

yarn add @pixelburp/phaser3-drag-select

How to use:

This operates as a global plugin in your Phaser Game, then loading it into your main gameplay scene. First you must define the new global plugin in your game's global config:

import DragSelectPlugin from '@pixelburp/phaser3-drag-select';
// ... any other imports for your project...

const config = {
    ...
    plugins: {
        global: [
            { key: 'DragSelectPlugin', plugin: DragSelectPlugin }
        ]
    },
    ...

Then, in the create() function / method of your main gameplay Scene (ie, the scene containing all the GameObjects you wish to be selectable), you set up the Plugin like so:

create() {
    this.dragSelect = this.plugins.start('DragSelectPlugin', 'dragSelect');

    this.dragSelect.setup(<MyScene>, {
        camera: <MainGameSceneCamera>,
        cameraEdgeAcceleration: 0.015,
        cameraEdgeBuffer: 50,
        childSelector: <Function>,
        dragCameraBy: 2,        // right-button
        mouseClickToTrack: 1,   // left-button
        mouseAmendSelectWith: 'shift',
        mouseToggleSelectWith: 'ctrl',
        outlineColor: 0x00ff00,
        outlineWidth: 2,
        onPreview: <Function>,
        onSelect: <Function>,
        rectBgColor: 0x33ff33,
        rectAlpha: 0.5,
        singleClickThreshold: 20,
    });
}

Setup Configuration

In the setup() method of the plugin, we pass in a configuration object. The possible values are

camera

What is the main "Gameplay" camera being used in this scene?

cameraEdgeAcceleration (default: 0.009)

The acceleration value to use when, during drag-selection, the mouse reaches the edge of the viewport / screen.

cameraEdgeBuffer (default: 50)

How close to the edge of the viewport / screen the cursor should be (during drag selection) before panning the camera

childSelector (default: return "interactive" children)

If you want, you can supply a custom function to determine what will count as a "selectable" GameObject. By default it checks for GameObjects that have input.enabled

dragCameraBy (default: 2)

The mouse button that controls how to pan the camera around. Default is 2, right-click. Set to false to disable altogether

mouseClickToTrack (default: 1)

The mouse button to track click-drag actions. Defaults to 1, the left-click.

mouseAmendSelectWith (default: shift. Possible values: alt|ctrl|shift)

Allow ability to amend your selection if this key is held down. Defaults to Shift key.

mouseToggleSelectWith (default: ctrl. Possible values: alt|ctrl|shift)

Allows ability to group select, if this key is held down. Defaults to Ctrl key.

outlineColor (default: 0x00ff00)

The color to use on the outline of the selection rectangle during dragging

outlineWidth (default: 2)

The width of the selection outline during dragging

onPreview (default: noop)

During dragging, this function callback returns any GameObjects already overlapping selection rectangle. Callback's arguments:

{
    items: [],
    isAmendActive: false|true,
    isSingleClick: false|true,
    isToggleSelect: false|true
}

onSelect (default: noop)

On mouseUp after a drag event, this function callback returns any GameObjects that returned true for childSelector. Callback's arguments:

{
    items: [],
    isAmendActive: false|true,
    isSingleClick: false|true,
    isToggleSelect: false|true
}

rectBgColor (default: 0x33ff33)

The background color to use on the selection rectangle during dragging

rectAlpha (default: 0.5)

The background alpha value to use on the selection rectangle during dragging

singleClickThreshold (default: 20)

The area of the selection rectangle that, on mouseUp, will still count as a "single click". Defaults to 20

Functions

setup(scene, config)

Kind: global function

| Param | Type | Description | | ------ | ------------------------- | ------------------------------------------------- | | scene | Phaser.Scene | Target scene to attach the plugin's logic against | | config | Object | Configuration object to pass to plugin |

isEnabled() ⇒ Boolean

Returns the current "enabled" status of the Plugin's "interface" scene

Kind: global function

setConfig(config)

Updates the plugin's configuration with new values

Kind: global function

| Param | Type | Description | | ------ | ------------------- | ------------------------ | | config | Object | new configuration object |

disable()

If enabled, disable the plugin

Kind: global function

enable()

If not already enabled, enable the plugin

Kind: global function