• Content Count

  • Joined

  • Last visited

About Andromedus

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Thank you for that, it's exactly what I needed. I hadn't twigged it was of the type Signal and that's the part of the docs I needed to be looking in. Cheers.
  2. Hi. I have this code:, this); which calls my resizeGame callback function when the game size is changed in my menu state. When I change state to my game state, the same resizeGame function in the old state is still being called. How do I cancel the callback? Thanks. :)
  3. Thank you very much Samme. Now my problem is that I have it working with mouse input using your code, but it doesn't work with touch input. Any ideas how that would be done? Cheers.
  4. This is embarrassing how long it's taking me to figure this out, but how the hell do you do this: 'var x = mySprite.mouseX' in Phaser? I've tried everything, read every document and example I can find, searched everywhere, and I'm guessing the answer must be so simple I'm looking straight past it. Cheers.
  5. Thanks Abhishek - that sounds like it might work - I'll give it a try.
  6. Thanks Nesh - so basically, I have two different control methods in my game, one for where a mouse is available, and one for where touch is available. It only just occurred to me that some have both mouse and touch enabled (like a desktop with a touch screen monitor), and was trying to figure out a ) how to detect that and b ) what to do in that scenario. But if there is no way to check if there is a mouse plugged in, that's going to be awkward. I get what you're saying, you can check for mouseMove events, but I assume that would also detect input from a track pad on a laptop, which wouldn't be a very easy way to play the game. I think I'll just stick with how it is already, so if touch is enabled, they'll get the touch control method, like it or lump it. I suppose I could work in a setup screen to give people the option but that seems like a bit of a faff - I'd rather keep things simple and get straight into the game.
  7. Hey guys, Is there a way in Phaser to check if a mouse is available? So far I've been using if(game.device.touch) in my code to distinguish between desktop and mobile devices, but as many desktops/laptops have touch as well, they will be treated as mobiles in my code, which isn't what I want. Thanks.
  8. Thanks samme - although game.scale.height just reports a static value for me, the original game height set using game.scale.setGameSize(), irrespective of any changes made to the browser window size. It appears to be the value stored before the any scaling is applied by the SHOW_ALL scale mode. Whereas using the pure javascript method - document.getElementById("parentDiv").clientHeight; - that appears to report accurately the actual height.
  9. What kind of transformations have been done to the chain of groups? If it's just position and rotation then I think it's reasonably easy maths to convert world coords into local coords. Of the top of my head, something like this I think: x(local) = (x(world) - x(group)) / cos(theta) where x(local) is what you are trying to find, the x coord local to the group in question, x(world) is the screen coord you already know, x(group) is the world position of the group in question and theta is the rotation of the group in relation to the world. If there's scaling going on as well, then it get trickier.
  10. Aha - I think I got it: document.getElementById("parentDiv").clientHeight; Seems to be what I was after.
  11. Thanks, but yeah, I tried both of those, and they are just reporting the original size I set, even after the browser window is scaled, rather than the real pixel value of the visible game area. I've also tried logging the 'parentBounds' argument from the resize callback ( game.scale.setResizeCallback ) and for some reason that returns a rectangle which is always 0,0,0,0. I have a feeling I'm overlooking something obvious. Is there a way to find how much scaleManager.SHOW_ALL has actually scaled the original size of the game? If I could get at that, then I could simply multiply that scale factor to the original dimensions to calulate the new pixel size of the game.
  12. If the render mode is set to Phaser.AUTO, then Phaser will be using webGL to render if it's available. So it's probably the gpu doing the work, which is why your cpu isn't being stressed. If you change the render mode to Phaser.CANVAS, then you should see the cpu working harder.
  13. Divide the coordinate by the snap value (16 in your case), then round the number to an integer, and then mutiply by the snap value. So, for example, you want to snap an x-coordinate of 37 to the nearest multiple of 16: var x = 37; var snapValue = 16; var snappedX = Math.round(x / snapValue) * snapValue; This will give snappedX as 32. (Nice game, by the way. You'll want to tween the tank to the nearest snap value on releasing the cursor key, so it's always in the right position before turning. And so that you don't get the tank moving backwards on releasing the key, you should change Math.round in the algorithm above to either Math.floor or Math.ceil depending on which direction it's going, so it always tweens forward to the correct position)
  14. Phaser may have a built-in method for this somewhere, but personally I would just use a bit of maths. Not tested but I think this should work: objectSprite.rotation = Math.atan2(targetSprite.y - objectSprite.y, targetSprite.x - objectSprtie.x);