AlexArroyoDuque Posted February 20, 2014 Share Posted February 20, 2014 Hi!I have found this in forum:http://www.html5gamedevs.com/topic/3400-tinting-sprite-color/?hl=tinting I use version 1.1.5. There are any example of how to create an effect of impact sprite? Link to comment Share on other sites More sharing options...
Telash Posted February 20, 2014 Share Posted February 20, 2014 One of the first things I did after discovering Phaser, was the edit some of the existing tutorials to try and add more functionality. I did a basic hit effect as part of this. It's a bit chaotic and and could be better (not very well done) but its something I swiftly through together to see what Phaser could do with regards to a standard platforming game. I hope this helps. Please note this was done using 1.1.3 however. // Shows the player sprite being knocked away from the enemy after taking a hit (being touched)function knockedBackAnimation() { player.animations.stop(); // Initialize knock back var distance = 75; if(knockedTo == 0) { immortal = true; knockedDirection = knockedbackDirection(player, monster); switch(knockedDirection) { case 'left': knockedTo = (player.body.x - distance); break; case 'right': knockedTo = (player.body.x + distance); break; } } switch(knockedDirection) { case 'left': player.frame = 11; knockedVelocityX= -500; // Parabolic knock back arc player.body.velocity.x = knockedVelocityX; if(player.body.x <= (knockedTo + distance/2)) { player.body.velocity.y = 100; } else { player.body.velocity.y = -100; } // Player has been knocked back as far as he needs to, reset if(player.body.x <= knockedTo || player.bottomLeft.x <= 0) { player.frame = 6; facing = 'right'; knockedTo = 0; knockback = false; } break; case 'right': player.frame = 1; knockedVelocityX= 500; // Parabolic knock back arc - A major pain in my ass player.body.velocity.x = knockedVelocityX; if(player.body.x >= (knockedTo + distance/2)) { player.body.velocity.y = 100; } else { player.body.velocity.y = -100; } // Player has been knocked back as far as he needs to, reset if(player.body.x >= knockedTo || player.bottomRight.x >= game.canvas.width + 30) { player.frame = 12; facing = 'left'; knockedTo = 0; knockback = false; } break; } // A ghostly visage for a short stint of immortality player.body.sprite.alpha = 0.5;} AlexArroyoDuque 1 Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted February 21, 2014 Author Share Posted February 21, 2014 thank you! I will try to incorporate it. I use version 1.1.5. Will it work? Link to comment Share on other sites More sharing options...
Telash Posted February 21, 2014 Share Posted February 21, 2014 I haven't tried this in 1.1.5, however it did work in 1.1.4. I think it SHOULD be fine. Link to comment Share on other sites More sharing options...
AlexArroyoDuque Posted March 24, 2014 Author Share Posted March 24, 2014 http://www.html5gamedevs.com/topic/4269-accessing-pixel-array-of-a-sprite/?hl=tint#entry26633 Link to comment Share on other sites More sharing options...
Recommended Posts