Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@pixi/react-ui #88

Open
273032860 opened this issue Aug 2, 2023 · 1 comment
Open

@pixi/react-ui #88

273032860 opened this issue Aug 2, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@273032860
Copy link

pixi/ui add react

export const Pixitest = () => {
const blurFilter = useMemo(() => new BlurFilter(4), [])
const ref = useRef()

useEffect(() => {
const button = new ButtonContainer()

const buttonView = new Graphics().beginFill('#A5E24D').drawRoundedRect(0, 0, 150, 150, 150)
const text = new Test2('🤙', { fontSize: 70 })
text.anchor.set(0.5)
text.x = buttonView.width / 2
text.y = buttonView.height / 2

buttonView.addChild(text)

button.addChild(buttonView)
ref.current.addChild(button.view)
console.log('ref.current:', ref.current)
console.log('button:', button)

}, [])

return (

<Sprite
image="https://pixijs.io/pixi-react/img/bunny.png"
x={400}
y={270}
anchor={{ x: 0.5, y: 0.5 }}
/>

  <Container x={400} y={330} ref={ref}>
    {/* <Text text="Hello World" anchor={{ x: 0.5, y: 0.5 }} filters={[blurFilter]} /> */}
  </Container>
</Stage>

)
}

Cannot render correctly

@273032860 273032860 added the enhancement New feature or request label Aug 2, 2023
@CyberDex
Copy link
Member

CyberDex commented Aug 3, 2023

@273032860 For react, it is probably worth to use just Button, not ButtonContainer. I am not familiar with react good enough but when we was preparing PixiUI to be integrated into https://github.com/pixijs/pixi-react we was discussing that container instance should be given to a component by react after the instance of the component itself is created. ButtonContainer is just a helper. Button should probably work as you expect. Otherwise you may go and check how is it integrated in https://github.com/pixijs/pixi-react

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

When branches are created from issues, their pull requests are automatically linked.

2 participants