Jump to content

react pixi events dont work


aabb
 Share

Recommended Posts

Hi, i'm absolutely new in react-pixi, spent like few days but nothing works. Can somwbody answer, why this example doesnt work? Neither of these mouse events dont work on sprite, but in examples which i saw they work. React-pixi v7

import React from "react"
import '../styles/styles.css'
 
import { Stage, Sprite } from '@pixi/react';
import img_obstacle from './game resources/img/basic/obstacle.png';
 
export default function Component(props) {
    return(
        <Stage width={750} height={550}>        
            <Sprite
                image={img_obstacle}
                x={300}
                y={300}
                interactive={true}
                pointerdown={() => {console.log("HI")}}
                pointermove={() => {console.log("HI")}}
                mousedown={() => {console.log("HI")}}
                mousemove={() => {console.log("HI")}}
                mouseover={() => {console.log("HI")}}
                mouseout={() => {console.log("HI")}}
                onMouseOver={() => {console.log("HI")}}
                onClick={() => {console.log("HI")}}
            />
        </Stage>  
    )
}
Link to comment
Share on other sites

I know it's quite a stupid answer, but I went crazy over a similar behaviour, with the canvas not registering any event except for mouseupoutside and the such.

In the end the problem wasn't related to PIXI itself, the page was just showing another component in front of it with the { display: none } CSS property, check that you're not facing a similar issue..

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...