Jump to content

[SOLVED] Getting normalized events from interactionManager (v5)


Xp1c3r
 Share

Recommended Posts

Hi, new here, been developing in pixi.js for a bit over two months now, absolutely love it. I have encountered something that I've been stuck on weeks that I hope someone can help me with. The issue is similar to the topic posted in 2019 but with a different use case.

Some context,
- I'm developing an ECS framework around pixi.js
- Wanted to capture normalized events from the InteractionManager to check for all sprite events at the same point
- Some events captured were (pointermove, pointertap) from originalEvent (chrome), and (mousemove, mouseover, mousedown, mouseup) from eventData but alas (mouseout, and some other events) are not working
- using additional plugins (gsap, pixi-layers)

Regular events in the documentation works as listeners attached to the sprite.
I needed to trigger those events under my Systems so I did a check on the interactionManager on every tick.
Is it the case that pointer-ized (standardized/working) event listeners only exists on PIXI.container but not on InteractionManager? If so do point me to the adapter class, i'll be eternally grateful :)
 
Do let me know if I'm missing any details, thanks!

Link to comment
Share on other sites

  • Xp1c3r changed the title to Getting normalized events from interactionManager (Pixi v5)

I'm developing an ECS framework around pixi.js

nice, that's usually how game engines are built on top of pixi

pixi-layers

I wrote custom TreeSearch in that plugin, so it can be wrong, a bit.

Is it the case that pointer-ized (standardized/working) event listeners only exists on PIXI.container but not on InteractionManager? 

pointer-ized events exist in InteractionManager somewhere, look around.

For your goal, CTRL+C-ing TreeSearch or whole interactionManager is fine, dont be afraid of doing that

Edited by ivan.popelyshev
Link to comment
Share on other sites

Hey ivan, thanks for your work and the quick reply.
Turns out after normalizeToPointerData() events are already what I tried previously and not what I needed.
I needed a way to have callbacks triggered on update instead of defining it on pixi elements.
It's just weird that events like 'pointerover' emitting when defining under sprites but doesn't show up after normalization in the InteractionManager.
I'll look for a workaround. Thanks.

Edit / Update: (Solved)

// normalization
let input = this.interaction.normalizeToPointerData(this.interaction.eventData)[0]
 
// checking for hits through treesearch
entity.on = (event, onCallback) => {
   this.interaction.processInteractive(event, entity.go, onCallback)
    return entity
}

This worked great for me. Thanks to pixi's modularity allowed me to do this.

    updateCards(){
        // InputManager.debug('Card')
        InputManager.check('Card', (card) => {
            card.on('pointerover', (go) => {
                if (!dragging) {
                    go.lastKnownX = go.x
                    go.lastKnownY = go.y
                    gsap.to(go, {
                        y: -350,
                        duration: 0.2,
                    })
                }
            }).on('pointerout', (go) => {
                if (!dragging)
                    gsap.to(go, {
                        x: go.lastKnownX,
                        y: go.parent.y,
                        duration: 0.2
                    })
            })
        })
    }


I think I got what you said after looking into the repo.
I recall a need to tweak the search for getting sprites under sprites in a post somewhere right? 

 

Edited by Xp1c3r
Link to comment
Share on other sites

  • Xp1c3r changed the title to [SOLVED] Getting normalized events from interactionManager (v5)

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...