Elad Sofer Posted April 23, 2014 Share Posted April 23, 2014 Hi, I am using phaser and am new to game development and could not find a solution to this question anywhere:I have a lizard character and want that when a mouse is clicked the mouth opens (i have that figured out) and a tongue will come out in a natural looking way to the point where i clicked and go back into the mouth after that.. I am clueless on where to begin and any leads or references will be great. Thanks,Elad. Link to comment Share on other sites More sharing options...
jpdev Posted April 23, 2014 Share Posted April 23, 2014 Maybe this can help you a little: http://janpeter.net/perma/phaser/rope.html I know it's not a tongue, but it's a sprite that is gradually stretched to a specific point, so maybe it helps.(Use view source to see the code - be advised it's an older phaser version, but it should still work the same way in the newer version) Link to comment Share on other sites More sharing options...
Elad Sofer Posted April 24, 2014 Author Share Posted April 24, 2014 Thank you for this.I have done it but it does not look very realistic... Because the tongue sprite stretches it looks very unrealistic Is there any other example that I can implement this in a snake like fasion, meaning that the base stays the same and the edge states the same but only the middle part stretches? Let me elaborate: How could I implement this:the tongue base is an animation, after that a tween to stretch only the middle and keep the edges?Thanks for your help,Elad. Link to comment Share on other sites More sharing options...
Elad Sofer Posted April 24, 2014 Author Share Posted April 24, 2014 I have found the solution that works for me (at least so far...). I calculated an array of points leading for the mouth of the lizard to the point clicked.And then i draw a base sprite and then repeat the "body" sprite as many times as needed and then draw the edge of the tongue.To create the "extraction" animation i start with 3 points (base,mid,edge) and incrementally draw more middle sprites and move the edge accordingly. Does that make sense? Is there a more elegant way of doing this in phaser (reminder - i am a complete newbie to phaser \ javascript \ game development)What do you think? Link to comment Share on other sites More sharing options...
OpherV Posted April 24, 2014 Share Posted April 24, 2014 Elad - can you post a mockup image of what exactly are you trying to achieve? Link to comment Share on other sites More sharing options...
valueerror Posted April 24, 2014 Share Posted April 24, 2014 here is one crazy example how you could create realistic movement of a snake-like lizard tongue ;-) don't know if it helps but it's fun to play with http://test.xapient.net/phaser/ALL/snake.html Link to comment Share on other sites More sharing options...
Elad Sofer Posted April 27, 2014 Author Share Posted April 27, 2014 valueerror: It does help thank you!Opher: This video is a good representation of what i am trying to achieve: Link to comment Share on other sites More sharing options...
Recommended Posts