kandi background

phaser | fast 2D game framework for making HTML5 games | Game Engine library

Download this library from

kandi X-RAY | phaser Summary

phaser is a JavaScript library typically used in Telecommunications, Media, Media, Entertainment, Gaming, Game Engine, Three.js, WebGL applications. phaser has no bugs, it has no vulnerabilities, it has a Permissive License and it has medium support. You can install using 'npm i @jwhite0042/phaser-ce' or download it from GitHub, npm.
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.

kandi-support Support

  • phaser has a medium active ecosystem.
  • It has 30320 star(s) with 6527 fork(s). There are 1246 watchers for this library.
  • There were 3 major release(s) in the last 12 months.
  • There are 167 open issues and 3571 have been closed. On average issues are closed in 75 days. There are 32 open pull requests and 0 closed requests.
  • It has a neutral sentiment in the developer community.
  • The latest version of phaser is v3.55.2

quality kandi Quality

  • phaser has 0 bugs and 0 code smells.

securitySecurity

  • phaser has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
  • phaser code analysis shows 0 unresolved vulnerabilities.
  • There are 0 security hotspots that need review.

license License

  • phaser is licensed under the MIT License. This license is Permissive.
  • Permissive licenses have the least restrictions, and you can use them in most projects.

buildReuse

  • phaser releases are available to install and integrate.
  • Deployable package is available in npm.
  • Installation instructions are not available. Examples and code snippets are available.
Top functions reviewed by kandi - BETA

Coming Soon for all Libraries!

Currently covering the most popular Java, JavaScript and Python libraries. See a SAMPLE HERE.
kandi's functional review helps you automatically verify the functionalities of the libraries and avoid rework.

phaser Key Features

Cerebral Fix

MoPub

Facebook

Game Distribution

GameCommerce

Mozilla

Texture Packer

TwilioQuest

Poki

CrazyGames

Lagged

Nakama

Clone the git repository via https, ssh or with the GitHub Windows or Mac clients.

Download as zip

Download the build files: phaser.js and phaser.min.js

phaser Examples and Code Snippets

  • NPM
  • CDN
  • TypeScript Definitions
  • Create Your First Phaser 3 Example
  • How to read position x of Shape Object when during tween
  • adding a property in a class inside d.ts file inside node_modules typescript
  • How can I properly scale Phaser sprites?
  • player object undefined only in update()ƒ
  • Getting last element on click every time in Javascript loop with Phaser JS
  • Integrate Phaser Game with React as component
  • Phaser 3 increase drag click area size of sprite
  • Phaser 3 How to Access and Affect Player in Collision between 2 Objects Not Involving Player
  • Webpack Define plugin replacement is evaluated but not injected
  • How can I stop animation loop, but not mid-animation in Phaser 3?

NPM

npm install phaser

Community Discussions

Trending Discussions on phaser
  • How to read position x of Shape Object when during tween
  • adding a property in a class inside d.ts file inside node_modules typescript
  • How can I properly scale Phaser sprites?
  • player object undefined only in update()ƒ
  • Getting last element on click every time in Javascript loop with Phaser JS
  • Integrate Phaser Game with React as component
  • Phaser 3 increase drag click area size of sprite
  • Moving the character a few tiles more seems to cause the whole scene (the physics world) to shake, why is that? How do I fix it?
  • Phaser 3 How to Access and Affect Player in Collision between 2 Objects Not Involving Player
  • Webpack Define plugin replacement is evaluated but not injected
Trending Discussions on phaser

QUESTION

How to read position x of Shape Object when during tween

Asked 2022-Apr-16 at 11:58

I have the Circle object that extends shape and am trying to get the value of x or position of the object in 2d plane. During animation (tween) the position does not update and remains static. How do i fix this ?

export class Circle extends Phaser.GameObjects.Shape {
    tween;
    constructor(scene:Phaser.Scene, x, y) {
        super(scene);
        let enemy = scene.add.circle(x, y, 20);
        enemy.setStrokeStyle(1, 0x05F9FB);
    
        this.tween = scene.tweens.add({
            targets: enemy,
            x: 560,
            y: 200,
            ease: 'Power1',
            duration: 3000,
            yoyo: true,
            repeat: -1
        });
    }
}

I have the below method in update method and it always returns original x value not the update one during tween.

update() {
    //Always returns  the orginal position of x and not the updated or current state of x
    console.log(enemy.x);
}

ANSWER

Answered 2022-Apr-16 at 11:58

The enemy position x and y is not the position of the circle, that is used in the tween. An easy option is, just to create a property, so that you can acess the position, from the property.

Here small example, how the access could work:

// Minor formating for stackoverflow
document.body.style = "display: flex;flex-direction: column;";    

class Circle extends Phaser.GameObjects.Shape {
    constructor(scene, x, y) {
        super(scene, x, y);
        this.circle = scene.add.circle(x, y, 20);           
        this.circle.setStrokeStyle(3, 0x05F9FB);
    
        this.tween = scene.tweens.add({
            targets: this.circle,
            x: 400,
            y: 120,
            duration: 3000,
            yoyo: true,
            repeat: 3
        });
    }
}

var config = {
    type: Phaser.AUTO,
    width: 536,
    height: 163,
    scene: {
        create,
        update
    }
}; 

function update(){
    this.info.setText(`x: ${this.enemy.circle.x.toFixed(0)}\ny: ${this.enemy.circle.y.toFixed(0)}  `);
}

function create () {
    this.enemy =  new Circle(this, 100, 100);
    this.info = this.add.text(20,20, '', 0xffffff);
}

var game = new Phaser.Game(config);
<script src="https://cdn.jsdelivr.net/npm/phaser@3.55.2/dist/phaser.js">
</script>

Update:

Info: To keep the code cleaner using a getter( and setter) or method might be cleaner

Like this

 class Circle extends Phaser.GameObjects.Shape {
     ...
     getPosition(){
         let { x, y } = this.circle;
         return { x, y };
     }
 }

Source https://stackoverflow.com/questions/71885987

Community Discussions, Code Snippets contain sources that include Stack Exchange Network

Vulnerabilities

No vulnerabilities reported

Install phaser

You can install using 'npm i @jwhite0042/phaser-ce' or download it from GitHub, npm.

Support

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.

Build your Application

Share this kandi XRay Report