Search the Community
Showing results for tags 'interactionevent'.
-
Hello, I am working on a game with pixi js. to make the game look normalized on every screen, im scaled the stage as follows this.scale=Math.max(this.viewWidth, this.viewWidth) / (2048 * this.ratio); and on orientation change I am rotating the whole stage. now my problem is, if i have any buttons on stage, who are at top or at right side of stage, they do not respond to any touch event. Please help i'm in a very big trouble. I tried to use mappositiontopoint as well. but didn't understand how to correctly use here. Please help
- 3 replies
-
- interactionevent
- pixi.js
-
(and 1 more)
Tagged with:
-
Hey everyone, this is my first post, so I hope I do this right. Let me explain, what I wanted to do: I created a GameObject class so that all my objects inherit from this class. The GameObject is interactive and I was thinking about to give it some default methods, that can be used for: this.on('pointerdown', <__put_default_function_here__>); If an object that inherit from GameObject needs a different action as you click on it, you can simply switch the callback function to another default method or you could create a new method inside the new object. So one of this default methods looks like this: //ECMA6 shot_this(from=this.parent.player) { console.log('POP!'); console.log(from); console.log('shot something:'); console.log(this); } As you can see, I thought that if i do this: "this.on('pointerdown', this.shot_this)" the from-variable would be undefinded and than would be set to my player object. But as it turns out, this is wrong. The first parameter of the callback function of .on() is the InteractionEvent. Now lets go to my Problem: My Problem is definitely not that the first parameter of the callback-function is the InteractionEvent, my problem is, that I can't check for it. The default method shot_this will be also used by an NPC AI to shot at things, so I must check if the first parameter is an InteractionEvent. Something like this isn't working: //ECMA6 shot_this(from) { if (from instanceof PIXI.interaction.InteractionEvent) { console.log('yeah it is an InteractionEvent'); } else { ... } } PIXI.interaction.InteractionEvent is always undefined. So my question is: How do i check if the first parameter is an InteractionEvent? And why is PIXI.interaction.InteractionEvent undefined, even if i try to access this by Chrome Developer Tools? I hope you understand my problem and can help me. Have a great day everyone!