Socket
Socket
Sign inDemoInstall

@ion-phaser-ce/react

Package Overview
Dependencies
11
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @ion-phaser-ce/react

React specific wrapper for @ion-phaser-ce/core


Version published
Weekly downloads
6
Maintainers
1
Created
Weekly downloads
 

Readme

Source

IonPhaser CE for React

Introduction

React specific wrapper for ion-phaser-ce component.

Why?

Most people who use React don’t use Web Components and there're some limitations handling data with Custom Components from React. Thus, this React component was created not to need to reference their Custom Elements using a ref and manually attach the game, this makes working with IonPhaser CE not cumbersome 👍🏻

Usage

  • Import Phaser CE dependencies before, check the example here:
window.PIXI = require('phaser-ce/build/custom/pixi');
window.p2 = require('phaser-ce/build/custom/p2');
window.Phaser = require('phaser-ce/build/custom/phaser-split');
  • Using the IonPhaserCe component:
import React, { useState } from 'react'
import Phaser from 'phaser-ce'
import { IonPhaserCe } from '@ion-phaser-ce/react'

const game = {
  width: "100%",
  height: "100%",
  renderer: Phaser.AUTO,
  state: {
    init: function() {
      this.stage.backgroundColor = '#24252A';
    },
    create: function() {
      this.helloWorld = this.add.text(
        this.game.world.centerX, 
        this.game.world.centerY, 
        "Hello World", { 
          font: "40px Arial", 
          fill: "#ffffff" 
        }
      );
      this.helloWorld.anchor.set(0.5);
    },
    update: function() {
      this.helloWorld.angle += 1;
    }
  }
}

export default function App () {
  // Call `setInitialize` when you want to initialize your game as a component! :)
  const [initialize, setInitialize] = useState(false);
  return (
    <IonPhaserCe game={game} initialize={initialize} />
  )
}

Supporting 🍻

I believe in Unicorns 🦄 Support me, if you do too. Professionally supported @ion-phaser-ce/react is coming soon

Happy coding 💯

Made with ❤️

Keywords

FAQs

Last updated on 15 Mar 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc