All Projects → proyecto26 → Ion Phaser

proyecto26 / Ion Phaser

Licence: mit
A web component to use Phaser Framework with Angular, React, Vue, etc 🎮

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Ion Phaser

svelte-webcomponents
A ready-to-use project template to build custom elements (web components) with Svelte 3 with support and examples for web components, jest, sass, nested components with props, eslinting, stylelinting, Github actions, propagating custom events from shadow-DOM to real-DOM etc.
Stars: ✭ 22 (-85.53%)
Mutual labels:  web-component, web-components, custom-elements
cwco
Powerful and Fast Web Component Library with a Simple API
Stars: ✭ 27 (-82.24%)
Mutual labels:  web-component, web-components, custom-elements
Ionic Pwa Toolkit
Build lightning fast Progressive Web Apps with zero config and best practices built-in. Go from zero to production ready with Ionic and Stencil (Web Components).
Stars: ✭ 629 (+313.82%)
Mutual labels:  ionic, web-components, ionic-framework
ionic-custom-components
🌈 Ionic Tutorial: Mastering Web Components in Ionic Framework. This repo is an Ionic project showcasing Angular custom components and Stencil custom web components.
Stars: ✭ 30 (-80.26%)
Mutual labels:  ionic, web-components, ionic-framework
Use Custom Element
Custom hook to bridge Custom Elements (Web Components) to React.
Stars: ✭ 77 (-49.34%)
Mutual labels:  web-components, custom-elements, web-component
Ionic Collection
🤘 Looking for about Ionic Framework?
Stars: ✭ 101 (-33.55%)
Mutual labels:  ionic, ionic-framework
Ionic Stencil Hn App
Ionic Stencil HackerNews App
Stars: ✭ 105 (-30.92%)
Mutual labels:  ionic, ionic-framework
Vanilla Hamburger
Animated hamburger menu icons for modern web apps (1.8 KB) 🍔
Stars: ✭ 110 (-27.63%)
Mutual labels:  web-components, custom-elements
Image Crop Element
A custom element for cropping a square image. Returns x, y, width, and height.
Stars: ✭ 115 (-24.34%)
Mutual labels:  web-components, custom-elements
Aybolit
Lightweight web components library built with LitElement.
Stars: ✭ 90 (-40.79%)
Mutual labels:  web-components, custom-elements
Nutmeg
Build, test, and publish vanilla Web Components with a little spice
Stars: ✭ 111 (-26.97%)
Mutual labels:  web-components, custom-elements
Generator Jhipster Ionic
Ionic for JHipster 💥
Stars: ✭ 147 (-3.29%)
Mutual labels:  ionic, ionic-framework
Calcite Components
Web Components for the Calcite Design System. Built with Stencil JS. Currently in Beta!
Stars: ✭ 96 (-36.84%)
Mutual labels:  custom-elements, web-component
Dataformsjs
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.
Stars: ✭ 95 (-37.5%)
Mutual labels:  web-components, custom-elements
Html Include Element
Easily include external HTML into your pages.
Stars: ✭ 143 (-5.92%)
Mutual labels:  web-components, custom-elements
Stencil
A toolchain for building scalable, enterprise-ready component systems on top of TypeScript and Web Component standards. Stencil components can be distributed natively to React, Angular, Vue, and traditional web developers from a single, framework-agnostic codebase.
Stars: ✭ 9,880 (+6400%)
Mutual labels:  ionic, custom-elements
Vaadin Combo Box
The Web Component for displaying a list of items with filtering. Part of the Vaadin components.
Stars: ✭ 113 (-25.66%)
Mutual labels:  custom-elements, web-component
Ionic4 Starter App Tutorial
Ionic 4 To Do List App. FREE Ionic 4 example app. Learn how to start using Ionic 4 to create a simple app with lists, forms and navigation.
Stars: ✭ 123 (-19.08%)
Mutual labels:  ionic, ionic-framework
Cnodejs Ionic
The mobile app of https://cnodejs.org made by Ionic 1.x, web demo http://lanceli.com/cnodejs-ionic
Stars: ✭ 1,537 (+911.18%)
Mutual labels:  ionic, ionic-framework
Elm Canvas
A canvas drawing library for Elm
Stars: ✭ 124 (-18.42%)
Mutual labels:  web-components, custom-elements

Built With Stencil Maintenance NPM version Downloads TotalDownloads Twitter Follow

IonPhaser

Web Component built with Stencil.js to integrate Phaser with any other framework.

IonPhaser

Inspired by the old IonPhaser directive

Demo

Do you want to see this web component in action? Visit https://codepen.io/jdnichollsc/full/oRrwKM yay! 🎉

IonPhaser CE

Looking for Phaser Framework CE (Community Edition)? Check here!

Usage

Simply add this tag wherever you want in your project:

<ion-phaser [game]="game"></ion-phaser>

Getting Started

Packages

Project Package Version Links
Core @ion-phaser/core version README.md
React @ion-phaser/react version README.md

Script tag

  • Put a script tag similar to this <script src='https://cdn.jsdelivr.net/npm/@ion-phaser/[email protected]/dist/ionphaser/ionphaser.esm.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

Node Modules

  • Run npm install @ion-phaser/core --save
  • Put a script tag similar to this <script src='node_modules/@ion-phaser/core/dist/ionphaser/ionphaser.esm.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install @ion-phaser/core --save
  • Add an import to the npm packages import @ion-phaser/core;
  • Then you can use the element anywhere in your template, JSX, html etc

Framework integrations

Angular

Using ion-phaser component within an Angular project:

Including the Custom Elements Schema

Including the CUSTOM_ELEMENTS_SCHEMA in the module allows the use of Web Components in the HTML files. Here is an example of adding it to AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core';
import { AppComponent } from './app.component';

@NgModule({
  declarations: [AppComponent],
  imports: [BrowserModule],
  bootstrap: [AppComponent],
  schemas: [CUSTOM_ELEMENTS_SCHEMA]
})
export class AppModule {}

The CUSTOM_ELEMENTS_SCHEMA needs to be included in any module that uses IonPhaser.

Calling defineCustomElements

IonPhaser component includes a function used to load itself in the application window object. That function is called defineCustomElements() and needs to be executed once during the bootstrapping of your application. One convenient place to add it is in the main.ts file as follows:

import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { defineCustomElements as defineIonPhaser } from '@ion-phaser/core/loader';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule)
  .catch(err => console.log(err));
defineIonPhaser(window);

Using IonPhaser in an Angular component

<ion-phaser
  [game]="game"
  [initialize]="initialize"
></ion-phaser>
public game = {
  width?: integer | string;
  height?: integer | string;
  zoom?: number;
  resolution?: number;
  type?: number;
  parent: HTMLElement | string;
  canvas?: HTMLCanvasElement;
  canvasStyle?: string;
  context?: CanvasRenderingContext2D;
  scene?: object;
  seed?: string[];
  title?: string;
  url?: string;
  version?: string;
  autoFocus?: boolean;
  input?: boolean | InputConfig;
  disableContextMenu?: boolean;
  banner?: boolean | BannerConfig;
  dom?: DOMContainerConfig;
  fps?: FPSConfig;
  render?: RenderConfig;
  backgroundColor?: string | number;
  callbacks?: CallbacksConfig;
  loader?: LoaderConfig;
  images?: ImagesConfig;
  physics?: object;
  plugins?: PluginObject | PluginObjectItem[];
  scale?: ScaleConfig;,
  instance: Game // It's created internally when the game is initialized
};

public initialize: boolean;

constructor(private api : ApiService){}

initializeGame() {
  this.game = {
    width: "100%",
    height: "100%",
    type: Phaser.AUTO,
    scene: {}
  }
  this.initialize = true
}

getInstance(){
  return this.game.instance
}

from stencil documentation

React

Specific Wrapper

When using a wrapper component, It's not necessary to access the reference directly to configure the game. More details here.

import React, { Component } from 'react'
import Phaser from 'phaser'
import { IonPhaser } from '@ion-phaser/react'

class App extends Component {
  state = {
    initialize: false,
    game: {
      width: "100%",
      height: "100%",
      type: Phaser.AUTO,
      scene: {}
    }
  }
  render() {
    const { initialize, game } = this.state
    return (
      <IonPhaser game={game} initialize={initialize} />
    )
  }
}

Web Component

Other option is using the web component directly:

import React from 'react'
import ReactDOM from 'react-dom'
import { defineCustomElements as defineIonPhaser } from '@ion-phaser/core/loader'
import Phaser from 'phaser'

const game = {
  width: "100%",
  height: "100%",
  type: Phaser.AUTO,
  scene: {}
}

ReactDOM.render(<ion-phaser ref={el => el.game = game} />, document.getElementById('root'));

defineIonPhaser(window);

from stencil documentation

Vue

In order to use the ion-phaser Web Component inside of a Vue application, it should be modified to define the custom elements and to inform the Vue compiler which elements to ignore during compilation. This can all be done within the main.js file as follows:

import Vue from 'vue';
import { defineCustomElements as defineIonPhaser } from '@ion-phaser/core/loader'

import App from './App.vue';

Vue.config.productionTip = false;
Vue.config.ignoredElements = [/ion-\w*/];

// Bind the IonPhaser custom element to the window object
defineIonPhaser(window);

new Vue({
  render: h => h(App)
}).$mount('#app');

Using IonPhaser in a Vue component

<template>
  <ion-phaser 
    v-bind:game.prop="game"
    v-bind:initialize.prop="initialize"
  />
</template>

<script>
import Phaser from 'phaser'
export default {
  name: 'HelloWorld',
  data() {
    return {
      initialize: false,
      game: {
        width: "100%",
        height: "100%",
        type: Phaser.AUTO,
        scene: {
          init: function() {
            this.cameras.main.setBackgroundColor('#24252A')
          },
          create: function() {
            this.helloWorld = this.add.text(
              this.cameras.main.centerX, 
              this.cameras.main.centerY, 
              "Hello World", { 
                font: "40px Arial", 
                fill: "#ffffff" 
              }
            );
            this.helloWorld.setOrigin(0.5);
          },
          update: function() {
            this.helloWorld.angle += 1;
          }
        }
      }
    }
  }
}
</script>

from stencil documentation

Contributing ✨

When contributing to this repository, please first discuss the change you wish to make via issue, email, or any other method with the owners of this repository before making a change.
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated ❤️.
You can learn more about how you can contribute to this project in the contribution guide.

Supporting 🍻

I believe in Unicorns 🦄 Support me, if you do too.

Enterprise 💼

Available as part of the Tidelift Subscription.

The maintainers of IonPhaser and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. Learn more.

Security contact information 🚨

To report a security vulnerability, please use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.

License ⚖️

This repository is available under the MIT License.

Happy coding 💯

Made with ❤️

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].