Quantcast
Channel: Pixi.js Latest Topics
Viewing all articles
Browse latest Browse all 3978

A virtual dom library for Pixi.js snabbpixi

$
0
0

I've written a virtual dom library for pixi.js. https://github.com/eguneys/snabbpixi

It only supports `PIXI.Container` and `PIXI.Sprite` but you can extend it to work for custom display containers.

It's used like this:

import * as PIXI from 'pixi.js';
import { init } from 'snabbpixi';
import { h } from 'snabbpixi';

const app = new PIXI.Application({});

app.loader
  .add("")
  .load(() => {

    let patch, vnode;

    function redraw() {
      vnode = patch(vnode, view());
    }

    patch = init([]);

    const blueprint = view();
    vnode = patch(app.stage, blueprint);
  };

function view() {
  return h('container', [
    h('sprite', {
     texture: PIXI.Texture.from('image.png')
    }),
    h('sprite', {
      texture: PIXI.Texture.from('image.png')
      x: 10,
      y: 10,
      height: 100,
      width: 100
    });
  ]);
}

 

Please take a look and use it, I will try to improve it as I make more games.


Viewing all articles
Browse latest Browse all 3978

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>