samid737

Members
  • Content count

    289
  • Joined

  • Last visited

  • Days Won

    1

samid737 last won the day on April 18 2017

samid737 had the most liked content!

3 Followers

About samid737

Contact Methods

  • Website URL
    https://github.com/samid737/

Profile Information

  • Gender
    Male
  • Location
    The Netherlands

Recent Profile Visitors

1,745 profile views
  1. To change attributes programmatically, you can try an object oriented approach. An example on how to achieve this in Phaser,: In the example, you basically extend the standard Phaser.Sprite object by adding some of your own requirements. The main requirement is that the Sprite must be swappable and so you define your own Swappable object. To switch properties of A character, you would need some sort of swap functionality. In the example, A swap function is added to the Phaser.Sprite prototype object. The swap function just keeps track of some index, and when you want to change that index, it does so via this function. You can customize the way you want to switch your objects (previous, next) by editing this function. Another requirement is to change properties, like sprite color, texture, maybe position etc. In Javascript there is A convenient way to assign properties to an Object, Object.assign(). In the example, you predefine some characters attributes (the beginning part of the code), and when you swap(), use Object.assign() to dynamically change your sprite to match those attributes. Note that these attributes must be valid Phaser.Sprite attributes, otherwise you are assigning things without any purpose, or worse, you could override some properties required by the engine. I think it should work for animated sprites too within Phaser, but the problem might be figuring out the display order. You could try to look at groups to deal with this.
  2. How to update an Arcade body?

    You don't need to add sprites during update for that. You can try adding the relevant child sprites during create, then enable their physics bodies for some frame: You could do the same using A group.
  3. bouncing ball maximum height

    You could try something parabolic: If you don't need physics, then you can also use sine / trigonometric functions to get A similar bounce motion : For vertical bounce, Yoyoing A bouncing tween could work.
  4. Angle towards Velocity

    atan2 should give you the angle in radians, so you could do: enemy.rotation = Math.atan2(enemy.body.velocity.y,enemy.body.velocity.x) //rotation is in radians
  5. Tilemap physics is recently implemented in 3.0.0 beta 13 . You can read trough the dev logs for details on other features as well.
  6. I'm currently experimenting and porting A game from v2 to v3 (fun). Is there any way we can lock A GameObject to A camera, similar to fixedToCamera? Mostly for locking UI related objects to the main viewport for instance.
  7. Habbo WebGL Game Engine

    Phaser does have A ready made isometric plugin, which is pretty similar to what habbo looks like and it includes physics (not sure if you need physics though). For the UI you can even consider using only DOM elements if it does not require too much animation. This game reminds me of the habbo UI in some way :http://www.dynetisgames.com/2017/03/18/phaser-quest/. You can also strip down features you don't need in A custom Phaser build. It could be done using Phaser, but if its the best way, i'm not sure......
  8. P2 physics - bodies attached and dangling upon rotation

    Sounds like A spring, something like this? The attached sprite can only rotate if it collides with other objects. If you want less dangling, lower the mass of the smaller sprite.
  9. You could try game.physics.arcade.overlap instead of game.physics.arcade.collide().
  10. Transfer sprite velocity to another sprite

    You could use P2 lockConstraints and break the link of two (half) sprites :
  11. This sounds like A particle system. Not sure if you can scale in one direction though. Otherwise you could update each sprite manually : //in update flamethrower.forEach(function(flame){scaleIt(flame)}); //somewhere in code function scaleIt(flame){ flame.scale.y = flame.x; // or lifespan }
  12. You could set the holes as zones where the sprite slows down: moreabout extending phaser sprites. You can slow it down by setting the strength as a function of the distance between the ball and the zone for example. Its more like skidding, but maybe its good enough for you. Otherwise you could try to add your own gravity to the game by defining some gravitational pull when the ball is close enough. Its pretty much doing the same thing, but the update function should be something like: Hole.prototype.update = function(){ dist = Phaser.Point.distance(ball,this) if(dist<this.size){ ball.body.acceleration.x = 1/(dist*dist)*this.strength; ball.body.acceleration.y = 1/(dist*dist)*this.strength; } }
  13. Body vs Sprite (ARCADE physics)

    Does sprite.width change the physics body size? You could try setSize when switching animation frames if you know each frame size. EDIT: nvm sprite.width or height does change the body size. Maybe the problem is in the spritesheet:
  14. The ball immediately collides either with world bounds or the other object when it is spawned. If you spawn the ball At for example 500,400 it won't move at all. The bouncing is either due to gravity or bounciness of the object. game.physics.p2.restitution sets the bounciness of all objects.
  15. I think it should be the other way around, inputDownAction(pointer, ballButton).