Sohail Ahmad Posted May 3, 2014 Share Posted May 3, 2014 Hello All, is there any idea how to shake screen when dog is fall down (i am talking about FlyingDog game built with panda.js). Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Midnight Posted May 3, 2014 Share Posted May 3, 2014 I don't know about panda.js, but generally you would update stage.x and stage.y (or whatever you are shaking) in every frame either based on Math.random() or sine function. Quote Link to comment Share on other sites More sharing options...
Sohail Ahmad Posted May 3, 2014 Author Share Posted May 3, 2014 Any sample code? Quote Link to comment Share on other sites More sharing options...
Midnight Posted May 3, 2014 Share Posted May 3, 2014 Well, you asked "is there any idea how to shake screen", I gave you a couple of ideas.Math.random() returns a random value between 0 and 1 (float value), which can be manupulated by multiplying, rounding, adding and subtracting from what you need.Math.sin(angle) returns a value between -1 and 1 based on the input angle (which can easily be a counter value, to which you add 0.1 on each frame for example). This second solution is harder and also needs a dampening function (which will reduce amplitude over time) to make for a realistic effect. Load all this to your brain, add a little bit of google and shake a little. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.