Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.

Overview

Phaser - HTML5 Game Framework

Phaser Header

Discord chat Twitter Follow npm GitHub

Phaser is a fast, free, and fun open source HTML5 game framework that offers WebGL and Canvas rendering across desktop and mobile web browsers. Games can be compiled to iOS, Android and native apps by using 3rd party tools. You can use JavaScript or TypeScript for development.

Along with the fantastic open source community, Phaser is actively developed and maintained by Photon Storm. As a result of rapid support, and a developer friendly API, Phaser is currently one of the most starred game frameworks on GitHub.

Thousands of developers from indie and multi-national digital agencies, and universities worldwide use Phaser. Take a look at their incredible games.

Visit: The Phaser website and follow on Phaser Twitter
Play: Some of the amazing games #madewithphaser
Learn: API Docs, Support Forum and StackOverflow
Code: 1770+ Examples (source available in this repo)
Read: The Phaser World Newsletter
Discord: Join us on Discord
Extend: With Phaser Plugins
Be awesome: Support the future of Phaser

Grab the source and join the fun!

What's New

7th June 2022

We've been quietly but solidly working away on Phaser 3.60 for months now and are very close to release. Today I'm happy to say that 3.60 Beta 9 has been published and I would urge you to test it, if you can do so. It should be a safe drop-in replacement for Phaser 3.55, with very little need for changes to your code. However, it does bring a lot of new features and fixes to the table.

Some of the new features include:

Sprite FX - The ability to create and use SpriteFX Pipelines directly on Sprite Game Objects. These allow a really easy way to define per-Sprite shaders, including extra padding space, perfect for effects such as blur, distort, glow, outline, shadow and more.

Compressed Texture Support - Phaser 3.60 contains support for Compressed Textures. It can parse both KTX and PVR containers and within those has support for the following formats: ETC, ETC1, ATC, ASTC, BPTC, RGTC, PVRTC, S3TC and S3TCSRB. Compressed Textures differ from normal textures in that their structure is optimized for fast GPU data reads and lower memory consumption. Popular tools that can create compressed textures include PVRTexTool, ASTC Encoder and Texture Packer.

Matter Physics v0.18 - We have updated the version of Matter Physics to the latest v0.18 release. This is a big jump and brings with it quite a few internal changes to Matter, as well as a ~40% performance improvement.

There are also hundreds of updates and bug fixes across the entire codebase.

As always, I have been careful to record all of these in their own Change Log. So it's easier for you to identify which change happened in the 3.60 version specifically.

Beta 9 is available now from the Releases page. You can also download it from npm:

I have published new TypeScript defs files that align with this version. You can find them in the types folder of this repository.

If you find any problems with this release I'd urge you to please report them in GitHub issues.

As usual, I'd like to send my thanks to the Phaser community for their help in both reporting issues and submitting pull requests to fix them. So, please do spend some time digging through the Change Log. I assure you, it's worth while :)

I'd like to send a massive thank-you to everyone who supports Phaser on Patreon, GitHub Sponsors and our corporate backers. Your continued funding allows me to keep working on Phaser full-time and this monster of a new release is the very real result of that. If you've ever considered becoming a backer, now is the perfect time!

If you'd like to stay abreast of developments then I'm now publishing them to the Phaser Patreon. Here you can find the latest development reports including the concepts behind Phaser 4.

You can also follow Phaser on Twitter and chat with fellow Phaser devs in our Discord.

Phaser 3 wouldn't have been possible without the fantastic support of the community and Patreon. Thank you to everyone who supports our work, who shares our belief in the future of HTML5 gaming, and Phaser's role in that.

Happy coding everyone!

Cheers,

Rich - @photonstorm

boogie

Support Phaser

Because Phaser is an open source project, we cannot charge for it in the same way as traditional retail software. What's more, we don't ever want to. After all, it's built on, and was born from, open web standards. It's part of our manifesto that the core framework will always be free, even if you use it commercially, as many of you do.

You may not realize it, but because of this, we rely 100% on community backing to fund development.

Those funds allow Phaser to improve, and when it improves, everyone involved benefits. Your support helps secure a constant cycle of updates, fixes, new features and planning for the future.

We use Patreon to manage the backing and you can support Phaser from $1 per month. The amount you pledge is entirely up to you and can be changed as often as you like. Patreon renews monthly, just like Netflix. You can, of course, cancel at any point. Tears will be shed on this end, but that's not your concern.

You can also support us by using crypto currencies. The Phaser wallet addresses are:

  • Ethereum: 0x6a716A122Ad186ECE865C55D16c1D361f1B13724
  • BSC / AVAX / Polygon: 0x94aC3F640b8749AbD1d44f29A62ffeB32CA34628

Extra special thanks to the following companies whose support makes Phaser possible:

Sponsors

Download Phaser

Phaser 3 is available via GitHub, npm and CDNs:

NPM

Install via npm:

npm install phaser

CDN

Phaser is on jsDelivr which is a "super-fast CDN for developers". Include the following in your html:

<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.js"></script>

or the minified version:

<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/phaser.min.js"></script>

API Documentation

Go to https://newdocs.phaser.io/ to read the docs online using our brand new interface. Use the links to navigate the namespaces, classes and Game Objects lists and also use the new search box.

The documentation for Phaser 3 is an on-going project. Please help us by contributing improved docs and examples.

TypeScript Definitions

The TypeScript definitions can be found inside the types folder. They are also referenced in the types entry in package.json.

Depending on your project, you may need to add the following to your tsconfig.json file:

"typeRoots": [
    "./node_modules/phaser/types"
],
"types": [
    "Phaser"
]

We recently published a new Phaser 3 TypeScript Project Template, which you can use to get started with if you like.

The TS defs are automatically generated from the JSDoc comments found in the Phaser source code. If you wish to help refine them then you must edit the Phaser JSDoc blocks directly, not the defs file. You can find more details about the parser we built in the scripts/tsgen folder.

Webpack

We use Webpack to build Phaser and we take advantage of its conditional build flag feature to handle renderer swapping. If you wish to use Webpack with Phaser then please use our Phaser 3 Project Template as it's already set-up to handle the build conditions Phaser needs. Recent changes to our build steps mean you should now be able to use any other packager, like Parcel, without any config changes.

License

Phaser is released under the MIT License.

Getting Started

Tutorials and guides on Phaser 3 development are being published every week.

We've 3 tutorials related specifically to creating Facebook Instant Games with Phaser:

Source Code Examples

During our development of Phaser 3, we created hundreds of examples with the full source code and assets ready available. These examples are now fully integrated into the Phaser website. You can also browse them on Phaser 3 Labs via a more advanced interface, or clone the examples repo. We are constantly adding to and refining these examples.

Hathora

Hathora is a framework for creating online multiplayer games with a focus on providing the best developer experience possible. The framework handles aspects such as State Synchronization, persistence, and authentication so that you can focus on building your game. Once you’ve built your game, you can deploy it to Hathora Cloud with a single command, and it will push your game to servers all over the world, automatically scaling up or down based on the user load. Visit the Hathora documentation to learn more.

Huge list of Phaser 3 Plugins

Super community member RexRainbow has been publishing Phaser 3 content for years, building up an impressive catalogue in that time. You'll find loads of plugins, from UI controls such as text input boxes, to Firebase support, Finite State Machines and lots more. As well as the plugins there is also a comprehensive set of 'Notes' about Phaser 3, going into great detail about how the various systems work. It's an invaluable resource and well worth checking out at https://rexrainbow.github.io

Create Your First Phaser 3 Example

Create an index.html page locally and paste the following code into it:

<!DOCTYPE html>
<html>
<head>
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/phaser-arcade-physics.min.js"></script> 
</head>
<body>

    <script></script>

</body>
</html>

This is a standard empty webpage. You'll notice there's a script tag that is pulling in a build of Phaser 3, but otherwise this webpage doesn't do anything yet. Now let's set-up the game config. Paste the following between the <script></script> tags:

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    physics: {
        default: 'arcade',
        arcade: {
            gravity: { y: 200 }
        }
    },
    scene: {
        preload: preload,
        create: create
    }
};

config is a pretty standard Phaser 3 Game Configuration object. We tell config to use the WebGL renderer if it can, set the canvas to a size of 800x600 pixels, enable Arcade Physics, and finally call the preload and create functions. preload and create have not been implemented yet, so if you run this JavaScript code, you will have an error. Add the following after config:

var game = new Phaser.Game(config);

function preload ()
{
    this.load.setBaseURL('https://labs.phaser.io');

    this.load.image('sky', 'assets/skies/space3.png');
    this.load.image('logo', 'assets/sprites/phaser3-logo.png');
    this.load.image('red', 'assets/particles/red.png');
}

function create ()
{
}

game is a Phaser Game instance that uses our configuration object config. We also add function definitions for preload and create. The preload function helps you easily load assets into your game. In preload, we set the Base URL to be the Phaser server and load 3 PNG files.

The create function is empty, so it's time to fill it in:

function create ()
{
    this.add.image(400, 300, 'sky');

    var particles = this.add.particles('red');

    var emitter = particles.createEmitter({
        speed: 100,
        scale: { start: 1, end: 0 },
        blendMode: 'ADD'
    });

    var logo = this.physics.add.image(400, 100, 'logo');

    logo.setVelocity(100, 200);
    logo.setBounce(1, 1);
    logo.setCollideWorldBounds(true);

    emitter.startFollow(logo);
}

Here we add a sky image into the game and create a Particle Emitter. The scale value means that the particles will initially be large and will shrink to nothing as their lifespan progresses.

After creating the emitter, we add a logo image called logo. Since logo is a Physics Image, logo is given a physics body by default. We set some properties for logo: velocity, bounce (or restitution), and collision with the world bounds. These properties will make our logo bounce around the screen. Finally, we tell the particle emitter to follow the logo - so as the logo moves, the particles will flow from it.

Run it in your browser and you'll see the following:

Phaser 3 Demo

(Got an error? Here's the full code)

This is a tiny example, and there are hundreds more for you to explore, but hopefully it shows how expressive and quick Phaser is to use. With just a few easily readable lines of code, we've got something pretty impressive up on screen!

Ourcade

Ourcade have published two great Phaser 3 books. They'll take you from getting set-up, through to finishing your first game using modern JavaScript or TypeScript and they're both completely free! They also publish a huge range of quality tutorials and videos, so be sure to check out their site every week.

HTML5 Cross Platform Game Development with Phaser 3

Learn the secrets of HTML5 game development with Phaser 3.50 while building a cross platform endless runner game. Designed both for beginners and skilled programmers, the course guides you from an empty folder introducing the bare bones of JavaScript to advanced Phaser 3 features. Find out more details about HTML5 Cross Platform Game Development with Phaser.

Building Phaser

There are both plain and minified compiled versions of Phaser in the dist folder of the repository. The plain version is for use during development, and the minified version is for production use. You can and should also create your own builds.

Custom Builds

Phaser 3 is built using Webpack and we take advantage of the Webpack definePlugin feature to allow for conditional building of the Canvas and WebGL renderers and extra plugins. You can custom the build process to only include the features you require. Doing so can cut the main build file size down to just 70KB.

Read our comprehensive guide on creating Custom Builds of Phaser 3 for full details.

Building from Source

If you wish to build Phaser 3 from source, ensure you have the required packages by cloning the repository and then running npm install on your source directory.

You can then run webpack to create a development build in the build folder which includes source maps for local testing. You can also npm run dist to create a minified packaged build in the dist folder. For a list of all commands available use npm run help.

Change Log

Change Log

Due to the increasing size of our Change Logs we have now split them up into four parts:

We've organized the Change Logs into commonly themed sections to make it more digestible, but we appreciate there is a lot in there. Please don't feel overwhelmed! If you need clarification about something, join us on the Phaser Discord and feel free to ask.

Contributing

The Contributors Guide contains full details on how to help with Phaser development. The main points are:

  • Found a bug? Report it on GitHub Issues and include a code sample. Please state which version of Phaser you are using! This is vitally important.

  • Before submitting a Pull Request run your code through ES Lint using our config and respect our Editor Config.

  • Before contributing read the code of conduct.

Written something cool in Phaser? Please tell us about it in the forum, or email [email protected]

Created by

Phaser is a Photon Storm production.

storm

Created by Richard Davey. Powered by coffee, anime, pixels and love.

The Phaser logo and characters are © 2011 - 2022 Photon Storm Limited.

All rights reserved.

"Above all, video games are meant to be just one thing: fun. Fun for everyone." - Satoru Iwata

Comments
  • TileMaps Broken in Safari (Phaser 2.2.0/1)

    TileMaps Broken in Safari (Phaser 2.2.0/1)

    TileMaps are very broken in Safari, and it seems to be due to 1 line of code which, if I comment it out, makes everything work fine. I'd create a PR but I do not know exactly how this particular rendering flag is used:

    The line is here:

    https://github.com/photonstorm/phaser/blob/master/src/tilemap/TilemapLayer.js#L677

    In method: Phaser.TilemapLayer.prototype.shiftCanvas

    context.globalCompositeOperation = 'copy';
    

    Example:

    http://jsfiddle.net/zq8hn23g/6/

    This works fine in all browsers except Safari. If you run the example, then click and drag on the canvas, you'll see the tilemap flicker in and out of visibility.

    Please let me know if you need any more info.

    opened by neurofuzzy 55
  • Preliminary PR for isometric support

    Preliminary PR for isometric support

    Hello ! I've been working on implementing isometric tilemaps for a while now.

    fixes https://github.com/photonstorm/phaser/issues/3618

    Summary of the changes and their rationale :

    • Added orientation field to the layer data, to prevent "this.layer.tilemapLayer.orientation" unwieldy calls in the engine code.
    • Changed pixelX and pixelY calculations for the tiles in isometric layers in updatePixelXY to display tilemaps correctly.
    • Changed WorldToTileXY and TileToWorldXY components to work with isometric tilemaps. I also changed every component (getTilesAtWorldXY, getTilesWithin...) that used to call both WorldToTileX and WorldToTileY to call the XY alternatives instead, because sadly with isometric coordinates you need to work on both at the same time when converting to/from the world coordinates.
    • Changed the renderers to use the tileset's sizes when displaying tiles (and not the tiles') when the map is isometric. This may seem weird - but in Tiled the tileset's tiles don't necessarily have the same height as the tiles, it's usually double, to allow for "block/cube" type isometric maps. Check my test's map (in assets/tilemaps) to understand this.
    • Adjusted culling for isometric dynamic layers. I felt like the cullpadding didn't really make sense for iso maps so I didn't include it, but I'm not so sure, let me know. As part of this, I added a isoCullDistances attribute to dyn layers in order for the user to decide how strict the culling is.
    • Allowed the parser to parse isometric maps.
    • Applied the linter ;) probably more adjustments I forgot.

    For staggered and hexagonal maps :

    • Changed pixelX and pixelY calculations ,Changed WorldToTileXY and TileToWorldXY components to work with them. They use the same culling as standard maps with modified values for the vertical axes. You can do tileToWorldY, worldToTileY separately with them but not the X variants because of the formulas.

    Comments : Tiled itself doesn't support proper object layer display. Proper being, detecting when objects are behind walls/ when they are not. They are displayed above the map in all cases. I might be wrong, but I believe changing it would require a significant rewrite of the renderer, in order to interleave the objects and the tiles. I think it's better to just let users sort it out with Z-indexes. Thus I decided not to implement it in the engine by default. Is that reasonable ?

    Thank you in advance for your feedback !

    Edit : ~Only standard isometric is supported for now, but staggered is just a formality at this point, would come a week later at most after this PR is accepted.~ Staggered and hexagonal map modes are now supported.

    💖 Feature Request 
    opened by svipal 42
  • Phaser doesn't work with Webpack and require

    Phaser doesn't work with Webpack and require

    Earlier I made an (ugly) pull request https://github.com/photonstorm/phaser/pull/1923 that made Phaser work with Webpack, but since 7a6de818e1c8742f0e4e3eb0ffb3dc80a280a0e5 I'm sorry to say that this doesn't work anymore.

    I'm getting

    Uncaught ReferenceError: PIXI is not defined
    

    from https://github.com/photonstorm/phaser/blob/6139071ebc918ddd8a1201279ebc7c70e645de8e/src/Phaser.js#L357

    For repro you can use the Webpack boilerplate found here https://github.com/photonstorm/phaser/pull/1924

    opened by mkristo 39
  • Arcade Collision Detection

    Arcade Collision Detection

    I just updated to 2.2.1 and was looking forward to new features and fixes. But with the new update I get a lot of trouble with the collision detection. An example is just the breakout-example of phaser itself. When I play it for quite some time (besides the fact that the paddle is flickering aournd some times) some of the collisions are not recognized and the ball just flies through the bricks. I have similar issues with 2 other games. It happens often, if you have hits directly followed by each other (e.g. between two lines of bricks in breakout).

    Setup: Phaser 2.2.1 Tested on: Desktop Browser: Firefox (up-to-date) Cordova-Build: Nexus 5 (up-to-date)

    EDIT: After turning my game into SlowMotion (to see the debug bounding boxes) it did not happen so far. BUT it did also not happen with earlier Phaser versions.

    opened by Jack0815 37
  • Use Typescript in Phaser

    Use Typescript in Phaser

    This repo is for Phaser 3 related issues only. If you've found an issue with Phaser 2 please see the Phaser CE (Community Edition) repo instead.

    This should not be used for technical support. If you're struggling trying to use Phaser then post your question to the forum, Slack or Discord channels. GitHub Issues are for bugs and feature requests only.

    API errors must include example code showing what happens, and why you don't believe this is the expected behavior. Issues posted without code take far longer to get resolved, if ever. Feel free to use a site such as jsBin or CodePen to demo the problem. If we can run it, and see the error, we can usually fix it.

    If your Issue contains any form of hostility it will be instantly closed and you will be blocked from access to all our repos.

    Be nice. We do this for free.


    Hi! Let me say that I'm a real fan of Typescript, and I try to evangelize as much as I can in projects that I see that they will earn really value for this.

    You have several issues related to the usage of Typescript outside the project (query). Because this does not expose a definition file for Typescript, is not easy as we as developers would like.

    I understand that Typescript would add somewhat complexity to the development of the project, but is important to notice that Typescript is just JS with types, and other nice features too if you would like to use them.

    You currently are using JSDocs for typing, and the development setup is being made with Webpack. Even when you are not using ES features, I think that the sole use of Webpack breaks the bottom line of complexity needed for Typescript usage.

    I really think that declaring Types, and Interfaces with Typescript will help the development of the project, but will ultimately help developers using this library. This migration can happen progressively, and there is not need for breaking changes for the current code.

    I'll try to write a module in Typescript, and make a PR to see what you think about it. Thanks.

    opened by michaeljota 35
  • Add unit tests

    Add unit tests

    Great library by the way! One glaring thing thats missing for me is unit tests. Phaser is used by thousands now and people rely on it for their apps, I think adding unit tests to the build step will give people more confidence going forward.

    Do you guys have a plan for adding them? I will be happy to contribute a PR with a setup for mocha similar to what we have in the backbone.marionette project. Would you accept the PR before I spend some time on it?

    I appreciate it may take some time to boost the test coverage and testing drawing the graphics on the canvas would be difficult but even basic tests that look at setting property values or ensuring events are fired would be a welcome addition.

    Thoughts?

    opened by ahumphreys87 35
  • [Phaser 3] TypeScript definitions

    [Phaser 3] TypeScript definitions

    Opening a tracking ticket to watch for TypeScript definitions for Phaser 3.

    (Edit: Please track this is #3224 - we're locking this issue for comments, that one is open)

    opened by jhurliman 33
  • Advanced Notice: Nested Container support will be removed soon

    Advanced Notice: Nested Container support will be removed soon

    This is just a heads-up for those who track issues that support for nested Containers will be removed from a forthcoming version of Phaser (not 3.12, but probably 3.13).

    The ability to create and use Containers will remain, but you will no longer be able to add a Container as a child of another.

    The reasons are two-fold:

    1. It will improve speed as we'll no longer need to do any iteration during matrix or bounds calculations.

    2. It will reduce API complexity (both internally and externally) - there are edge-cases where, for example, a deeply nested Game Object doesn't inherit the correct blend mode. Or issues like input handling needing to crawl up a container tree to find its ultimate position, all of which are adding un-needed code into the API and causing issues (both for you and me).

    It's no secret that I never actually wanted Containers to be added as a feature at all. Look at the quality games made in Construct or Game Maker, for example, neither of which offer the feature. They have caused so much branching and additional work in the API that I really question their value, but at the same time, I know some devs like using them. So I won't outright nuke them (although, believe me, I've come close many times!) - but I do question their implementation. I think there is room to explore recoding the feature entirely, but in the meantime stopping the use of nested Containers will help mitigate a number of problems.

    opened by photonstorm 31
  • Mask behaviour when there are nested containers.

    Mask behaviour when there are nested containers.

    Hi,

    We have a component kind of List. It basically extends Container and creates children which are also of type Containers. Each of these children contain a background image and some text objects to display data, they are aligned vertically in the parent list container. Now the issue is when we are trying to apply mask to the parent container , the text children in second level containers are not being rendered at all. Only the background image is rendered.

    Further more input events seems to be working on the game objects which are masked .


    Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

    👩‍💻 Code example needed 🥈 Priority: Medium 
    opened by kanthi0802 29
  • "Only orthogonal map types are supported in this version of Phaser"

    https://github.com/photonstorm/phaser/blob/28e27647233cfa1fcefa4db1ccc7101a51264cac/src/tilemaps/parsers/tiled/ParseJSONTiled.js#L41

    When will non-orthogonal maps be supported? Specifically for my use-case, hexagonal maps?


    Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

    💖 Feature Request 🥉 Priority: Low 🙏 Help Wanted 🗺️ Tilemap 
    opened by njt1982 28
  • [2.4] Button callback doesn't trigger on click

    [2.4] Button callback doesn't trigger on click

    In 2.4.0, the button callback doesn't trigger on mouse click. With phone touch works fine (and the same code works under 2.3). Maybe related to the changes to Input.Mouse?

    Code (trivial, but you never knows...):

    var aButton = this.add.button(400, 300, 'aButton', function() {
                console.log('aButtonCallback');
                            //do stuffs
            }, this);
    
    🙇‍♂️ User to test 
    opened by Chris-Carvelli 27
  • Incorrect type for Tiled custom properties field in Tilemap and another classes

    Incorrect type for Tiled custom properties field in Tilemap and another classes

    Version

    • Phaser Version: v.3.55.2
    • Operating system: Windows 11
    • Browser: All browsers

    Description

    Tilemap and other entities are working with Tiled map data has incorrect type annotation for properties field.

    https://github.com/photonstorm/phaser/blob/ec18bf6ac77f1ae6e36258d1105b831069984c28/src/tilemaps/Tilemap.js#L191-L198

    On Tiled documentation pages the scheme of Map properties field is described as array of properties, not an object. This is correct for another Tiled entities, like layer, chunk, objects, etc.

    Example Test Code

    I prepared a little example with simple JSON map exported from Tiled 1.9.2. https://codesandbox.io/s/cool-surf-vbetsr?file=/scenes/HelloWorldScene.ts

    In example we can see that's array's methods don't be allow for tileset.properties field.

    Additional Information

    I made some jsdoc types for describe Tiled custom properties and check how it generate in tsgen utility in Phaserjs repository. It generate correct TS types, but I don't so confident for edit existing Tilemap and another classes. if it is useful please feel free to use it.

    🐛 TypeScript Bug 
    opened by Creepypoke 4
  • LoaderPlugin: improved dynamic asset loading

    LoaderPlugin: improved dynamic asset loading

    I'm working on a game that needs to frequently and dynamically load a lot of assets while players are playing. Preloading most assets up front is not possible. Blobbing and URL encoding seem to be the culprits.

    Blob caching in Phaser is great, but each assets blob encoding process wreaks havoc on the main thread which then causes animation stutter. Limiting the max parallel downloads can help, but ultimately blobs stack up and block the main loop.

    Might be a couple approaches:

    • Run Blob creation and URL.createObjectURL inside a webworker. These are heavy operations to run on the main thread
    • Queue and RAF Blob creation and URL.createObjectURL to minimize their impact on the main loop.

    My current workaround around feeds the loader one asset then waits for the loader to complete and repeats. It doesn't give much control over when the blob gets created and encoded so animation stutter still occurs on weak devices, but is generally better.

    💖 Feature Request 🗃 Loader 
    opened by TomorrowToday 4
  • Pixel sprites from createFromAseprite are distorted in 3.60.0

    Pixel sprites from createFromAseprite are distorted in 3.60.0

    Version

    • Phaser Version: 3.60.0-beta.17
    • Operating system: macOS
    • Browser: Chrome

    Description

    Pixel-based sprites are distorted in 3.60.0. This could be isolated to only sprites generated from "createFromAseprite". This issue does not exist in 3.55.x. Please see codepen below to example and steps to replicate.

    Example Test Code

    https://codesandbox.io/s/distorted-sprites-mpdted?file=/src/index.ts

    opened by likwidgames 2
  • x based stagger axis not supported for hexagonal tilemaps

    x based stagger axis not supported for hexagonal tilemaps

    Version

    • Phaser Version: Phaser 3.55.2
    • Operating system: Windows 111
    • Browser: Chrome

    Description

    the render result in hexagonal mode is so different with tiled. result from Phaser image result from Tiled image

    seems there are addition space added in both direction.

    Example Tes

    titled52 t Code

    relative tiled tmx file, not able to attach , so just copy over

    <?xml version="1.0" encoding="UTF-8"?> <map version="1.9" tiledversion="1.9.2" orientation="hexagonal" renderorder="right-down" width="14" height="14" tilewidth="52" tileheight="24" infinite="0" hexsidelength="12" staggeraxis="x" staggerindex="odd" nextlayerid="4" nextobjectid="1"> <editorsettings> <export target="anhui..tmj" format="json"/> </editorsettings> <tileset firstgid="1" name="titled" tilewidth="52" tileheight="24" tilecount="12" columns="12"> <image source="titled52.png" width="624" height="24"/> </tileset> <layer id="1" name="图块层 1" width="14" height="14"> <data encoding="csv"> 3,3,3,3,3,7,3,3,3,3,3,3,3,3, 3,3,3,3,3,7,3,3,9,9,3,3,3,3, 3,3,3,3,3,7,3,1,3,3,9,3,3,9, 3,3,3,3,3,7,7,7,7,7,9,9,9,3, 3,3,3,3,3,7,3,3,1,7,3,7,3,7, 3,1,3,3,3,3,8,3,3,1,7,1,7,3, 1,1,1,9,9,9,7,7,7,3,1,3,3,3, 1,11,11,3,9,3,9,9,7,7,3,3,3,9, 11,1,1,3,3,3,3,9,9,9,9,9,9,9, 3,3,3,3,3,9,9,9,9,9,9,9,9,3, 9,9,9,9,9,9,9,3,3,8,7,7,7,7, 9,9,9,9,9,3,3,1,3,7,3,1,1,1, 3,3,3,3,3,1,1,1,7,3,1,1,1,3, 3,3,3,3,1,3,1,3,7,1,1,3,3,3 </data> </layer> </map>

    Additional Information

    💖 Feature Request 🗺️ Tilemap 
    opened by edushare 2
  • Issue with POINTER_UP_OUTSIDE

    Issue with POINTER_UP_OUTSIDE

    Version: Phaser Version: 3.55.2 Browser: Windows Chrome 107

    I'm running into an interesting problem, and I think I have it narrowed down to the cause, and it's possible that it's expected behavior. I have a game that is running on our website, the game runs inside of an iframe where the contents are on a different domain than the website. We use to have document.domain set, but have recently removed it as it is getting deprecated. I noticed that some of our games weren't working correctly if you were dragging something in the game, dragged your mouse of the game area, and then released. Generally what would happen is the item wouldn't get "dropped" and would continue to follow your mouse.

    It seems like the mouseup event is not firing for the game when you release outside of the game. After a bit of diving into Phaser's code, it looks like the mouseup listener for when the mouse is released outside of the game was being down by doing window.top.addEventListener('mouseup') which obviously doesn't work without document domain setting, so it falls back to just using window.addEventListener. The relevant code is found here: https://github.com/photonstorm/phaser/blob/v3.55.2/src/input/mouse/MouseManager.js#L475

    I created a simple setup that results in the problem:

    const contentWrapper = document.getElementById('contentWrapper');
    const canvas = document.createElement('canvas');
    canvas.width = 1024;
    canvas.height = 768;
    contentWrapper.appendChild(canvas);
    canvas.addEventListener('mousedown', () => console.log('mouse down on canvas'));
    window.addEventListener('mouseup', () => console.info('mouse up on window'));
    
    class Example extends Phaser.Scene {
      create () {
        this.input.on(Phaser.Input.Events.POINTER_UP_OUTSIDE, () => console.info('phaser pointer up outside'));
        this.input.on(Phaser.Input.Events.POINTER_UP, () => console.info('phaser pointer up'));
    
        this.add.text(this.scale.width / 2,this.scale.height / 2, 'This is a test Phaser game', { align: 'center', color: '#ffffff', fontSize: '32px', fontFamily: 'Arial' }).setOrigin(0.5);
      }
    }
    
    /** @type {Phaser.Types.Core.GameConfig} */
    const config = {
      type: Phaser.WEBGL,
      width: 1024,
      height: 768,
      parent: 'contentWrapper',
      canvas,
      scale: {
        mode: Phaser.Scale.FIT,
        autoCenter: Phaser.Scale.CENTER_BOTH
      },
      scene: Example
    };
    
    const game = new Phaser.Game(config);
    

    I noticed if I didn't create the Phaser game (comment out the last line of code), the canvas/window listeners work - you get the "mouse up on window" if you click inside of the canvas, and then release outside of the canvas. Once the Phaser game is created, that stops working.

    After a bit more digging, I found that adding the following to the config fixes the issue: input:{mouse:{preventDefaultDown:false}}. The relevant code that this is used is here: https://github.com/photonstorm/phaser/blob/v3.55.2/src/input/mouse/MouseManager.js#L391. I am assuming that what is happening is the event gets its "prevent default" called, which prevents it from correctly firing on the window. I'm not 100% sure why turning off the down prevent default fixes it for the up event, but turning off the prevent default for up doesn't fix it. I would assume the reason why the window.top version works is because that has its own mouse up event that is fired, so it wouldn't have prevent default set on it.

    Again, this might be expected behavior. I'm not sure what ramifications turning off preventDefaultDown would have, so I'm hesitant to do that. In the meantime I'm going to look at other solutions but maybe someone can shed some light on why this happens the way it does, and whether there might be a solution.

    An additional note: POINTER_UP_OUTSIDE works correctly on our website on Windows Firefox, but doesn't work correctly on Windows Edge. Not sure about Mac browsers, and the structure of our website on mobile is different so it "works" on mobile but the page setup is different so I don't think the issue is relevant on there.

    Final note: I noticed that Phaser 2.11.0 works. After diving through that code, it doesn't seem like they prevent default on any of the events - there's a way for that to be turned on, but it looks like it is off by default.

    ⌨️ Input 
    opened by sreadixl 1
  • Reverse order in which indexes are substracted when sorting gameobjects for inputs

    Reverse order in which indexes are substracted when sorting gameobjects for inputs

    This PR

    • Fixes a bug

    Describe the changes below:

    When setting the topOnly property to false on the InputPlugin, the game objects receive the events in reverse render object (i.e bottom-most object receives before top-most).

    This feels counterintuitive as they should be receiving them from top to bottom.

    This PR aims to fix that by modifying the sortGameObjects method.

    opened by LaP0573 0
Releases(v3.60.0-beta.17)
Owner
Richard Davey
Full time HTML5 Game Developer and creator of Phaser, Atari otaku, Retro Gaming Geek, child of the 80s, demoscener, anime and pixel art fan.
Richard Davey
Making Tetris (Video Game) by using Phaser (Typescript).

Phaser 3 + TypeScript + Parcel Template For people who want to spend time making Phaser 3 games in TypeScript instead of configuring build tools. This

Poom Yimyuean 3 Nov 3, 2022
Recreated Chromium T-Rex game in Phaser 3, written in HTML5 & TypeScript

Chromium Dino Game - Phaser 3 + TypeScript + Parcel Chromium Dino Game Clone using Phaser 3 + TypeScript + Parcel Play You can play online here Dino P

Mai Hoàng Anh Vũ 3 Jun 21, 2022
A template application for setting up a mobile app video game with IONIC, PHASER, ANGULAR and a Monorepo strategy

OpenForge Ionic Monorepo Example This is a template project for all you aspiring video game developers out there! Want to use your web application ski

OpenForge 67 Dec 22, 2022
This package generates a unique ID/String for different browsers. Like chrome, Firefox and any other browsers which supports canvas and audio Fingerprinting.

Broprint.js The world's easiest, smallest and powerful visitor identifier for browsers. This package generates a unique ID/String for different browse

Rajesh Royal 68 Dec 25, 2022
Learn design patterns through games with TypeScript and Phaser 🕹️

Welcome to Design patterns gamified! I created this repo to teach design patterns through games. Each folder contains a tiny game that demonstrates ho

Paula Santamaría 41 Nov 10, 2022
A table component for your Mantine data-rich applications, supporting asynchronous data loading, column sorting, custom cell data rendering, row context menus, dark theme, and more.

Mantine DataTable A "dark-theme aware" table component for your Mantine UI data-rich applications, featuring asynchronous data loading support, pagina

Ionut-Cristian Florescu 331 Jan 4, 2023
2D HTML5 rendering and layout engine for game development

Stage.js is a 2D HTML5 JavaScript library for cross-platform game development, it is lightweight, fast and open-source. Check out examples and demos!

Ali Shakiba 2.2k Jan 3, 2023
Smooth mobile touch slider for Mobile WebApp, HTML5 App, Hybrid App

iSlider iSlider is a lightweight, high-performant, no library dependencies cross-platform slide controller. It can help handling most sliding effects,

Baidu BEFE 1.7k Nov 25, 2022
Next-gen mobile first analytics server (think Mixpanel, Google Analytics) with built-in encryption supporting HTTP2 and gRPC. Node.js, headless, API-only, horizontally scaleable.

Introduction to Awacs Next-gen behavior analysis server (think Mixpanel, Google Analytics) with built-in encryption supporting HTTP2 and gRPC. Node.js

Socketkit 52 Dec 19, 2022
A game inspired by Go, developed using Phaser JS

Influence A game inspired by Go, developed using Phaser How to play Players take turns to select and color a tile. At the end of a turn, each tile wil

null 11 Aug 28, 2022
A browser game build with phaser 3 during the Ludum Dare 50 GameJam.

Loading... ?? It’s him again! In front of your home this human appears! And with him soon again this pesky progress bar! Fight the data packs with all

Fabian 3 Aug 22, 2022
Clinton Mbonu 20 Jun 30, 2022
This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X and O on a 3x3 grid.

Tic Tac Toe Game This is a Tic Tac Toe game built with HTML, CSS, and JavaScript. It is a simple and fun game where two players take turns marking X a

Andrew Tsegaye 4 Mar 4, 2023
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
JavaScript image gallery for mobile and desktop, modular, framework independent

PhotoSwipe v5 — JavaScript image gallery and lightbox Demo | Documentation Repo structure dist/ - main JS and CSS src/ - source JS and CSS. src/js/pho

Dmytro Semenov 22.4k Dec 29, 2022
API, web and mobile application for finding a partner to play online multiplayer games.

Duo Finder Duo Finder is a simple mobile and web application for gamers looking for partners to play a game with. It's basics was developed during the

José Guilherme Fernandes Moura 2 Sep 20, 2022