Sign in to follow this  
Wesley W

Why isn't work while click on stage?

Recommended Posts

Hi,

This is my codepen : http://codepen.io/WW/pen/LGzpVv

what i wanna do is trying click on stage and get the mouse position value,

but, there's nothing happens while clickiing on stage.

the official example looks working great : http://pixijs.github.io/examples/index.html?s=demos&f=graphics-demo.js&title=Graphics

but mine isn't.

so, anyone any idea?

thanks for help. :)

 

PS : i guess the problem might because the stage width & height isn't fit to the renderer. just guess, still trying....

Share this post


Link to post
Share on other sites

It isn't working, because you have empty container. In this case you need to set hitArea for it :
 

stage = new PIXI.Container();
stage.interactive = true;
stage.hitArea = new PIXI.Rectangle(0, 0, w, h);

and adjust it in on_resize()

stage.hitArea.width = w;
stage.hitArea.height = h;

 

Share this post


Link to post
Share on other sites

You have nothing on the stage so nothing gets clicked. Add something and the click events are triggered. Also setting the stage width & height will scale the stage based on the width and height of stage. For example if you have a child in stage that is 100x100 px then setting the width and height of stage would be same as saying: stage.scale.x = w/100; stage.scale.y = h/100;

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.