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

@phaserjs/editor-scripts-arcade

v2.0.2

Published

Phaser Editor audio scripts.

Downloads

5

Readme

Phaser Editor Arcade Physics Scripts (library)

Warning: This project is deprecated. It is now part of the @phaserjs/editor-scripts-quick library.

This project contains a few Phaser Editor scripts for setting Arcade physics to objects.

These script nodes are very basic and may fit on any Phaser Editor project.

The scripts are coded in TypeScript with ES modules.

Installing (NPM)

This package depends on the following packages:

  • @phaserjs/editor-scripts-core

To install this in your game you have to install dependencies too:

npm install @phaserjs/editor-scripts-core
npm install @phaserjs/editor-scripts-arcade

Also, you should add this package to the phasereditor2d.config.json file in your project, in the scripts section:

{
    "scripts": [
        "@phaserjs/editor-scripts-core",
        "@phaserjs/editor-scripts-arcade",
    ]
}

Installing (vanilla JavaScript)

  • Get the files in the browser folder and copy them into your JavaScript project. It includes Phaser Editor files, JavaScript files, and TypeScript type definitions.
  • Add a script tag to the index.html file to load the lib/phaserjs_editor_scripts_arcade.js file.

Summary

This library provides a couple of actions and events about the Arcade Physics system in Phaser. As a reminder, an action is executed by an event script or another action.

The events:

  • On World Bounds Collide Event - Is fired when an object collides with the world bounds.

The actions:

  • Set Velocity Action - Sets the velocity of the script's game object.
  • Set X Velocity Action - Sets the velocity's X value to the script's game object.
  • Set Y Velocity Action - Sets the velocity's Y value to the script's game object.
  • Get GameObject From Body Action - Gets the game object for the given physics body.
  • Make Object Collider Action - Creates a physics collider with the game object.
  • Set Body Enable Action - To enable/disable physics in the game object.
  • Start Flip With Velocity Action - Starts flipping the game object heading to the velocity vector.
  • Start Follow Pointer Action - Starts moving the game object toward the pointer position.
  • If Body Touching - A conditional action to test if the body touching state.

The base classes:

  • Base Arcade Object Script - A base class for Arcade-related scripts (prefab variants).

On World Collide Event

Class: OnWorldBoundsCollideEventScript

This script listens to the worldbounds event. When the event is fired, it executes the children's scripts.

The event is fired only for objects with the body's onWorldBounds parameter set to true.

You can configure the sides of the world this event listens to, with the UP, DOWN, LEFT, RIGHT parameters.

Set Velocity Action

Class: SetVelocityActionScript

This action sets the given X and Y velocity to the game object.

Set X Velocity Action

Class: SetVelocityXActionScript

This action sets the given X velocity to the game object.

Set Y Velocity Action

Class: SetVelocityXActionScript

This action sets the given X velocity to the game object.

Get Game Object From Body Action

This action gets the game object from the given body. The body is passed to this action in the first argument, and this action passes, in the first argument, the associated game object to the children. You can combine this action with the On World Bounds Collide Event event.

If Body Touching

This action tests the game object body.touching state. If it is touching, it executes the actions of the Then actions node, else, it executes the actions of the Else actions node.

This action provides the Left, Right, Top, and Bottom boolean parameters. If any of these parameters is true and the body touching state of the same side is true, then we say the object is touching and then execute the Then actions.

This action allows the Action Target component.

Make Object Collider Action

This action creates a collider with the game object and the given Collide With object. If you check the Overlap Only parameter, then it uses an overlap instead of a collide method.

When there is a collision, this action executes the children nodes and passes as argument the collision event arguments.

This action allows the Action Target component.

Set Body Enable Action

This action updates the body's enable state with the Enable parameter's value.

This action allows the Action Target component.

Start Flip with Velocity Action

This action starts monitoring the game object velocity vector and change the flip state of the game object.

If the Flip Horizontal is on, then it changes the flipX property of the object. If the Flip Vertical is on, then it changes the flipY property of the object.

By default, it assumes the object is facing left and top in its initial position. You can change it with the Facing Left and Facing Right parameters.

This action allows the Action Target component.

Start Follow Pointer Action

This action starts monitoring the pointer and moves the game object towards the pointer's position.

This action allows the Action Target component.