V
V
vasIvas2015-09-24 21:53:07
JavaScript
vasIvas, 2015-09-24 21:53:07

How to know that the cursor is over the container?

I have a very complicated question, but still I hope to get an answer to it. On English-language SO, I failed.
So - I have a square - Graphics. I put it in a container - Container. How can I know that the cursor is over the square?
Just do not need to talk about the ways you heard somewhere to check for intersections and others.
How to do this using pixi.js?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
Curly Brace, 2015-09-24
@stasuss

I'm not sure that I understood the question, but the pixie is a stupid render. you drew a square and that's it. there is no essence of it. you need to save the coordinates of its rectangle and then yes, check if the mouse is over these coordinates (if you need to do this globally on the entire page, you can translate the canvas coordinates into page coordinates)

D
Deodatuss, 2015-09-24
@Deodatuss

document.elementFromPoint(x,y)

E
Elizaveta Borisova, 2015-09-24
@Elizaveta

Pixi, while not strictly a renderer, is a core library upon which more abstract tools are built. Check out phaser if you want more out of the box.
better think about why this functionality is not there

S
sim3x, 2015-09-25
@sim3x

www.goodboydigital.com/pixijs/examples/6/
see the example source code

// set the mouseover callback..
    button.mouseover = function(data){
      
      this.isOver = true;
      
      if(this.isdown)return
      
      this.setTexture(textureButtonOver)
    }
    
    // set the mouseout callback..
    button.mouseout = function(data){
      
      this.isOver = false;
      if(this.isdown)return
      this.setTexture(textureButton)
    }
    
    button.click = function(data){
      // click!
      console.log("CLICK!");
    //	alert("CLICK!")
    }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question