Jump to content

Search the Community

Showing results for tags 'mouse event'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 6 results

  1. Hello everyone!, I'm stuck with my 2d game.. i'm trying to give certain sprites a on mousehover event(i dont really know if this is possible lel but i am really new with canvas so pleas help me out). does anyone know a better way or the sollution for this??? regards, slyvan25
  2. hi there, my current version is 4.5.1, and I found a possible issue, if I do 1. click mouse's left button on a sprite (fire onDown event) 2. keep the left button, then press the right button 3. keep the right button, then release the left button (onUp is not fired) 4. release the right button (onUp is still not fired) so basically, the right click would influence mouse event, which as I tested is normal in version 4.3.5 thanks
  3. Hi I am trying to write a tiny program so that my sprite can move to my mouse position on the broswer (viewport content area). However, the method I am using is not accurate, the sprite always goes a few pixels away of my mouse position. I wonder if there is a better way to do this. Currently my code is like this: const stage = new Container(); stage.interactive = true; stage.hitArea = new Rectangle(0, 0, 600, 600); stage.mousemove = moveHandler; const c = document.createElement('canvas'); // build a canvas element const sprite = Sprite.from(c); function movehandler(event) { const x = event.data.global.x; const y = event.data.global.y; sprite.rotation = Math.atan2(y - sprite.y, x - sprite.x); } function play() { sprite.x += 2 * Math.cos(sprite.rotation); sprite.y += 2 * Math.sin(sprite.rotation); } function animate() { requestAnimationFrame(animate); play(); renderer.render(stage); } animate(); The sprite moves when my mouse moves but it doesn't go to the same direction. It always goes slightly away from my mouse position, maybe 3-4 pixels. I have also tried to update the sprite's rotation every tick but the problem still exists. When I am not using PIXI.js I don't get this kind of problem. What is the correct way to make my sprite move to the right direction of my mouse in PIXI.js v4?
  4. First off, PIXI is incredibly new to me so the problem might lie in my incompetence. What I did: var localOffset = mouseData.data.getLocalPosition(mouseData.data.target); console.log(JSON.stringify(localOffset)); mouseData being the input of multiple different mouse events (mousedown, mouseup, rightdown, rightup, mouseover) The rotation of my sprite is set to 0. What happens: The console prints {x:xval, y:yval} where xval changes when moving up/down and yval changes when moving rigth/left. As far as I can tell, everything else seems to work with x increasing towards the right and y increasing towards the bottom of the screen. I can easily work around this but it felt report worthy. Additional stuff that might be of interest: The local position seems to be correctly offsetted by the anchor. What feels wrong to me is that the distance does not take into account the width/height of the actual sprite, only the width/height of the texture being used. This might actually be working as intended but is not what I expected. Have a nice day, - Michael Ok, so it gets weirder (for me). To make sure no rotation data is screwing with me I hardcoded the rotation to different values. Rotation does not seem to influence my results. x and y are not only swapped, the sign of x (value found in y) is also inverted I get the expected values when using a PIXI.Container() instead of a sprite (no xy swap, no inverted sign).
  5. Hi I am new to PIXI. I want to make my player sprite follow my mouse on the screen. How can I achieve that? I am using PIXI v4. I have read the docs and I have found PIXI.interactions.InterationManager which takes a renderer as its parameter. Something like this: I have also found some codes that just listen to the `mousemove` event on the stage or on the sprite. Which one is the correct way to do in PIXI v4? I assume this is a very simple task because I can do it easily with pure javascript. But I just can't get it to work in PIXI. I wish I could find the solution on the books or the examples but all they mention are just dragging the sprites which is not what I want. I also want to know if I should put the event listening out of my animation function or inside it because it seems it can get the mouse position outside of my animation function.
  6. Hello guys, I've been tickering around with EnchantJS and I have been unsuccessful on finding a way to find the mouse coordinates without touching/clicking on the screen. I plan on making a RTS project and I will need to have the mouse coordinates available for the commander to move around the map freely without having to click to do so. Does anyone know how to do this?
×
×
  • Create New...