Hi everyone, my first post on the forums and I really appreciate anybody's help with this problem.
ActionScript Code:
_root.currentMouseX = 275;
_root.currentMouseY = 200;
_root.lastMouseX = 275;
_root.lastMouseY = 200;
onEnterFrame = function(){
_root.currentMouseX = _root._xmouse;
_root.currentMouseY = _root._ymouse;
xMouseDiffPos = (_root.currentMouseX - _root.lastMouseX)*0.4;
xMouseDiffNeg = (_root.lastMouseX - _root.currentMouseX)*0.4;
yMouseDiffPos = (_root.currentMouseY - _root.lastMouseY)*0.4;
yMouseDiffNeg = (_root.lastMouseY - _root.currentMouseY)*0.4;
if(_root.currentMouseX < _root.lastMouseX){
_root.viewBox._x -= xMouseDiffNeg;
}
if(_root.currentMouseX > _root.lastMouseX){
_root.viewBox._x += xMouseDiffPos;
}
if(_root.currentMouseY < _root.lastMouseY){
_root.viewBox._y -= yMouseDiffNeg;
}
if(_root.currentMouseY > _root.lastMouseY){
_root.viewBox._y += yMouseDiffPos;
}
_root.lastMouseX = _root._xmouse;
_root.lastMouseY = _root._ymouse;
}
The vCam is called viewBox. So in terms of mathematics, and the logic in my head, this code should work perfectly. The scene has a center point. When I place my mouse over the center point, I also want the vCam to be centered. However this is not the case. After moving the mouse around for 30 seconds or so, there is a noticable shift in placements.
Unless I am missing something, each time I move the mouse away from the center, the amount moved by the vCam should be equaled when I move the mouse back.
It seems the Pos values on both axis' are not strong enough or the Neg values are too strong, therefore creating an imbalance. I've tried different multiply values but i can't seem to get it perfect, and it should work with the same values anyway.
My explanations might not be perfectly clear so I've uploaded an example .fla file and I'd be happy to PM anybody with the link (seeing as I'm a new user)
I appreciate all that can help with this problem, it seems so simple yet gives me headaches