fire7side Posted February 25, 2016 Share Posted February 25, 2016 I can't seem to add a polygon to a stage. Probably something simple. I made just a square to see if I messed it up, but same thing. When I comment out the addChild line for the poly it works. When I uncomment it says: Uncaught TypeError: t.emit is not a function var scn4 = { getStage:function(){ this.name = "Scene"; this.polyPts = [0,0,0,100,100,100,100,0]; this.poly = new PIXI.Polygon(this.polyPts); this.stage = new PIXI.Container(); // this.bg = new PIXI.Sprite( PIXI.loader.resources["assets/img/dogRoom.jpg"].texture ); this.test = new PIXI.Sprite( PIXI.loader.resources["assets/img/test.jpg"].texture ); this.stage.addChild(this.bg); this.stage.addChild(this.test); //this.stage.addChild(this.poly); return this.stage; } } Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 25, 2016 Share Posted February 25, 2016 var graphics = new PIXI.Graphics(); graphics.beginFill(0xffffff); graphics.drawPolygon(this.polyPts); graphics.endFill(); Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 25, 2016 Author Share Posted February 25, 2016 OK, thanks. Do you set it to alpha if it's invisible? I just want it to check for a mouse click on a sprite, not as something to see.. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 25, 2016 Share Posted February 25, 2016 You can set "alpha" field of graphics object, but you have to switch interaction on/off separately from it. Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 25, 2016 Author Share Posted February 25, 2016 I see now. I don't need to add the polygon as a child. I can just add it as a variable. I just need to pass it the x,y coordinates from the sprite click to find out if it fell inside the polygon. Then it doesn't cause an error. Quote Link to comment Share on other sites More sharing options...
fire7side Posted February 25, 2016 Author Share Posted February 25, 2016 Yes, hitArea is apparently an undocumented member of Sprite. If buttonMode is set to true it only turns into a hand on the hitArea, not the rest of the Sprite with no code on my part. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted February 26, 2016 Share Posted February 26, 2016 @fire7side yep, that's exactly how it works Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.