Skip to content

Latest commit

 

History

History
61 lines (46 loc) · 1.47 KB

README.md

File metadata and controls

61 lines (46 loc) · 1.47 KB

Create Pixi.js experiences using JSX and Signals

Install

npm install --save solid-pixi solid-js pixi.js

Basic Usage

import { Texture, type PointLike } from 'pixi.js'
import { createSignal } from 'solid-js'
import { Application, Assets, Sprite, useApplication } from 'solid-pixi'

function ClickContainer() {
  const app = useApplication()
  const [scale, setScale] = createSignal(1)

  return (
    <Sprite
      texture={Texture.from('https://pixijs.com/assets/bunny.png')}
      interactive
      pointerdown={() => {
        setScale(s => s * 1.25)
      }}
      scale={{ x: scale(), y: scale() }}
      anchor={{ x: 0.5, y: 0.5 } as PointLike}
      x={app.screen.width / 2}
      y={app.screen.height / 2}
    />
  )
}

export function Click() {
  return (
    <Application background="#1099bb" resizeTo={window}>
      <Assets load={[['https://pixijs.com/assets/bunny.png']]}>
        <ClickContainer />
      </Assets>
    </Application>
  )
}

Contributing

Sure, go ahead and fork.

solid-pixi is a pnpm monorepo so run pnpm install from the root of the workspace.

Source code can be found in /packages, with the main published package in /packages/solid-pixi

Developing

cd packages/docs && npm run dev will run the example page to quickly iterate on components