1 decade ago by cjennison
I'm currently having trouble understanding the math behind flicking and object and how to execute it in javascript..
I currently am using:
Update Function
My issues are in:
The Angle and how to calculate it
The Speed, am I calculating it correctly?
Acceleration, the entity starts slow and accels, is there a way to have it start faster and slow down with the friction?
I currently am using:
Update Function
var time = this.launchTimer.delta(); var ball = this.getEntitiesByType(EntityPlayer)[0]; if (ig.input.pressed('leftButton')){ this.launchTimer.reset(); xStart = nX; yStart = nY; } if (ig.input.released('leftButton')){ xEnd = nX; yEnd = nY; yresult = (yEnd - yStart); xresult = xEnd - xStart; console.log("L " + xresult); ball.launch(xresult, yresult); }
var nX; var nY; var xStart; var xEnd; var xresult; var yStart; var yEnd; var yresult; Canvas.addEventListener('touchstart', function(event){ ig.input.actions['mouse']=true; nX=event.touches[0].pageX; nY=event.touches[0].pageY; }, true); Canvas.addEventListener('touchmove', function(event){ ig.input.actions['mouse']=true; nX=event.touches[0].pageX; nY=event.touches[0].pageY; }, false); Canvas.addEventListener('touchend', function(event){ ig.input.released['mouse'] = true; nX=event.touches[0].pageX; nY=event.touches[0].pageY; },false);
My issues are in:
The Angle and how to calculate it
The Speed, am I calculating it correctly?
Acceleration, the entity starts slow and accels, is there a way to have it start faster and slow down with the friction?