cub

Members
  • Content Count

    16
  • Joined

  • Last visited

  1. cub

    bounce problem

    If "layer" from game.physics.arcade.collide(player, layer, onCollide); is a group that contain only object where you want bounce effect there should be no problem. The function onCollide will start only when you hit your special zone. And then it checks if you are touching.up. You may check the other side (down, left, right) is false to be sure you are not collide your special zone at left for exemple and your are hitting, at the same time, an other sprite on the top.
  2. Here a codepen (I prefer JSFiddle but tonight big latency on it..) http://codepen.io/anon/pen/ynGIp Only works on Chrome.. (wtf?) The assets animations don't load due to the crossdomain security issue. So on the green bloc it doesn't work, but on the worldbounds it flicks. May be in the next release of Phaser, set a better "onFloor()" function to return if player is trully on the floor (not only for worldbounds or tilemap) ? Lewster32 you can take a loot at my code but don't waste too much time ^^ I may (big may ~ no more holiday ) code my own 'dummy velocity gravity' function for the player and just test collision with overlap. Because I found very weird the fact that sprite control the body that control sprite ^^ In my opinion, body should be the only puppet master with just option with pivot/offset x/y of the sprite. Anyway thanks lewster32 to spend time here.. Hope few ones offer you beers in UK
  3. You may store your "this" to a variable // my contextvar that = this;function AA(){ that.BB();}function BB(){}or Use the bind option ( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind ) function.bind(context, param1, param2, ...)
  4. cub

    bounce problem

    Sorry but... can you explain what you want with a draw ? function onCollide(a, {"a" is a reference of your first params in game.physics.arcade.collide() and "b" the second So "a" === player and "b" === layer in my last post. object a will not bounce when first hit, after first hit, it will bounce You want to delay the bounce ?
  5. To put onFloor() to true. Phaser return true when it collides to the worldbounds but not when it stays on a platform (like a velocity.y === 0)
  6. Thanks lewster32 but.. Changing this.sprite.anchor.setTo(0.5, 0.35); to this.sprite.pivot.y = -10; fail, it flicks too. Changing this.sprite.anchor.setTo(0.5, 0.35); to this.sprite.body.setSize(12, 25, 0, -10); fail, it flicks too (the reset doom the sprite/body, reseting position etc..) Solutions (?) 1 - Use non-trimmed image/animation and if tomorrow I draw an animation for my cat that requiert larger space I have to re-export everything (and waste space in the image). 2 - Set a timer check on change anim like : function wantToChangeAnimAnchor(){ if (game.time.now - this.timeLastChangeAnim < 100){ return false; } ...}3 - Set bigger value on condition is cat falling/jumping to start animation like : if (this.sprite.body.velocity.y < -100) { this.changeAnim('jump');} else if (this.sprite.body.velocity.y > 100) { this.changeAnim('fall');}4 - answer 42
  7. Hmmm.. If a sprite have no body phys you can move it freely. If we add a body phys to it, you can't move it, the phys move it for you. For me the anchor should act like an offset of the sprite relative to his body phys. Is it possible to set an offset in pixel (not relative unit like anchor) to a sprite animation without change the phys ? With trimmed images/animations it sounds me "fatality" ^^
  8. cub

    bounce problem

    What physical system do you use? With P2.js you can use the materials to vary friction/restitution... See : http://schteppe.github.io/p2.js/demos/restitution.html http://examples.phaser.io/_site/view_full.html?d=p2%20physics&f=platformer+material.js&t=platformer%20material With Arcade you can check collide with game.physics.arcade.collide(player, layer, onCollide);And check touching (up, down, left or right) function onCollide(a, { if (a.body.touching.up === true) { // particular bounce when top hit }}
  9. Hmmm yes you are right. I can change the anchor on axe X but if I change the Y then the body flick. It's weird that the anchor changes values of physics body. As if the physical body was a child of the sprite. In my animation, the body(image) of the cat change so I have to redifine the position of the sprite relative to its body(arcade phys). Edit : If I change the value of the condition is cat falling/jumpg to higher value (before +/-2, to +/-50) if (this.sprite.body.velocity.y < -50) { this.changeAnim('jump');} else if (this.sprite.body.velocity.y > 50) { this.changeAnim('fall');}It stop flick (ok it flick on ~3frames) but not infinite flick. If somone have a good pratice about onFloor / anchor / animation, " I'm all ears "
  10. Hi everybody, Little up for this ! The value of body.onFloor() still flickering on Phaser v2.0.7 with animations Exemple : http://www.cubcubcub.com/bugonfloor/ The velocity Y constantly changing (0 ~ 4.5). And is there a way to set a sprite/body as floor ? For the moment on the collider event function, I set the body.blocked.down to true to return onFloor() true but is there a better way ?
  11. Sorry to dig up this topic but I had some problem of alignment too, from multiple flash movieclip to a single sprite sheet. My problem was the alignment between each animations, + between the rectangle collision and the scale -1/1 on the sprite (move left, move right). Put all the animation in the same timeline didn't solve my problem. The prop/function " .anchor.setTo() " saved me. Everytime I change to an animation, I set the anchor like this : this.sprite.animations.play('jump');this.sprite.anchor.setTo(0.5,0.4);[...]this.sprite.animations.play('fall');this.sprite.anchor.setTo(0.6,0.5);Voila
  12. Thank you for your feedback. I'm going to do a sprite (couple of tiles @atlas) and a concave polygon with P2.js for each islands. It reminds me Flash/Box2D
  13. Take a look to this tutorial http://gamemechanicexplorer.com/#bullets-5
  14. Hi, I'm trying to do an infinite runner with random islands. Island should be a tilemap generated dynamically. The character have to jump over and over island to survive. All exemples I saw with tilemap is a static map limited world. I want to use tilemap to skin it easily and access to which tile character collide (for special event). I tryed to put some velocity to tilemap/tilelayer or change to x/scrollx, like a kinectic body, but it fails. Sorry if my explanation isn't very good.. I made a draw to be more cleary : So is there a way to do something like this directly with Phaser ?
  15. I confirm that the new regexp works * Fixed the IE11 version check (fixes #579)