QLNEO

Members
  • Content count

    54
  • Joined

  • Last visited

  1. Please take a look at the two following pieces of code: // Form 1 paddle.events.onDragStart.addOnce(ball.setMovement, ball); // Form 2 paddle.events.onDragStart.addOnce(function() { this.setMovement(); }, ball); Technically these two should be the same. But, for some reason, the first variant isn't quite working according to the plan. In fact, ball is being sent as an argument to .setMovement() instead of being the context, as the docs make me think it should be. The second form works as expected, ball being treated as this. Is this a bug, an example of badly explained documentation or I'm missing something obvious?
  2. Database?

    You don't need to know databases to make games. You might want that if you're doing an online thing, though. I can't answer about the ads, but many games and some portals use ingame ads, so it's possible. Ad-supported games are one way to monetize your software, albeit licensing to portals seem to be the most effective in the short term.
  3. TypeError: this.game.add is not a function

    game.add is indeed not a function. It's a reference to GameObjectFactory, which itself has methods like .sprite(), .group() and, as gauravD mentioned, .existing(), which is great when you have to add a generic GameObject.
  4. Tween duration precision?

    It's likely. From my testing (as I said, the duration, or at least the looping, seems to be incremental), it appears that the tween loops starting with a frame update. I ended up using the Timer instead, that did the trick.
  5. Is there a way to make the game detect you're moving a pointer in a circular fashion? My idea would be to calculate velocity of a projection on a line perpendicular to the supposed centerpoint of the circle, but that sounds it could get a little inaccurate.
  6. Tween duration precision?

    I'm trying to sync a looping tween to a beat, by calculating the tween duration (therefore, the interval) from the BPM. But it's always off-sync! I investigated a bit by subtracting small values to see if I reach some kind of "fake sync", but it turns out the tween seems to be incremental (maybe with the frame updates?), and that won't do. Should I try using the Timer instead or there's a better way?
  7. Can't collide sprite and tilemap

    Well the Discord server saved my butt turns out there was something you did there that I forgot to do. Namely, put the .collide() on the update function. Problem solved, and I have to seriously write that up somewhere so I never ever forget that again. Thanks for the assistence though!
  8. Can't collide sprite and tilemap

    How so? But nevertheless, I define my player after the collision layer, which is exactly what you did. My game currently has only that layer (and an object layer, that isn't created because it's an object layer and just stores data)
  9. Drawing the UI with the DOM

    From what I understand you want a DOM UI that updates when something changes ingame, correct? Maybe you don't need a framework, but something like RxJS?
  10. Can't collide sprite and tilemap

    Looking at your code, I'm still not seeing any reason for mine to fail!
  11. Can't collide sprite and tilemap

    Well, the foreground is the collision layer. I forgot to change the names though, gonna fix that real quick
  12. Jet again, phaser offline

    There's NWjs as well. It does about the same thing Electron does.
  13. Can't collide sprite and tilemap

    So, I have trouble with this every project I start, but this time I really can't put my finger on it. Basically, it's the same old "sprite doesn't collide with tilemap", but look... let stage = game.add.tilemap("test-map"); stage.addTilesetImage("test-tileset","test-tileset",16,16); let foreground = stage.createLayer("foreground"); stage.setLayer("foreground"); foreground.resizeWorld(); stage.setCollisionByExclusion([]); let player = game.add.sprite(x,y,"key","frame"); // Don't worry, "x" and "y" are above the tiles and sprite gracefully falls through the tiles due to gravity game.physics.arcade.enable(player); player.body.gravity.y = 100; player.body.collideWorldBounds = true; game.physics.arcade.collide(player, foreground); Both sprite and tilemap have collision, as you can see. They are set to collide in the last line. The sprite even collides with the world bounds, but not with the tilemap. What could possibly be wrong with my setup?
  14. [Physics p2] Reduce drag to 0 (not mouse drag)

    I know this question is over a year old, but it's worth knowing that as of today (Phaser-CE 2.9.1) you can actually set the ball to have circular collision with Arcade Physics. You have to use sprite.body.setCircle(radius) for that.
  15. Drag sprite from anywhere?

    I want to drag a sprite with the pointer being clicked anywhere on the screen, having the sprite move relative to the pointer when it's pressed down. enableDrag() only lets me drag the sprite when I click on it first, so any ideas on how to achieve that?