When creating the "zoom" system, my "shake" system started to conflict with it. Thus, if I want to return the camera coordinates to their original position when shaking, zooming starts to work incorrectly, and even no "offsets" help me if line 58-60 is active (highlighted below) Please help.
The first video shows the boss with shaking, but without returning the camera to its original position - so the zoom works correctly.
The second video shows the boss also with shaking, but I activated the 58-60 lines, which return the camera coordinates to the original position; clearly shows that the zoom does not work correctly.
Line 58-60 in step
Create Event
Step Event
End Step
How i do correctly camera return after shaking? Without the strange shifting that is shown in the second video
I mean, I know that's the reason, but how do I get it to work right?
The first video shows the boss with shaking, but without returning the camera to its original position - so the zoom works correctly.
The second video shows the boss also with shaking, but I activated the 58-60 lines, which return the camera coordinates to the original position; clearly shows that the zoom does not work correctly.
Line 58-60 in step
GML:
view_xview[1] += view_xview[0] - view_xview[1]
view_yview[1] += view_yview[0] - view_yview[1]
Create Event
GML:
snapDiv = 32; //determines how fast the camera snaps to the player (higher numbers follow the player slower), can be changed in creation code
if (instance_exists(objPlayer))
{
x = objPlayer.x;
y = objPlayer.y;
}
//Zoom block
act = 0;
time = 0;
type = 1; // type 1 - trigger; type 2 - code function
zoom = 30;
wview = noone;
hview = noone;
xoffset = 0;
yoffset = 0;
viewNum = 0;
//Shake block
shake = 0;
//Camera block
view_visible[0] = false;
view_visible[1] = true;
GML:
// Zoom block
wview = zoom * 16;
hview = zoom * 9;
switch(type)
{
case 1:
if act = 1// and view_wview[0] != wview and view_hview[0] != hview
{
time += 1;
view_wview[viewNum] = EaseInSine(time,view_wview[viewNum],wview,64)
view_hview[viewNum] = EaseInSine(time,view_hview[viewNum],hview,64)
view_xview[viewNum] = EaseInSine(time,view_xview[viewNum],(room_width /2)-wview/2,64)
view_yview[viewNum] = EaseInSine(time,view_yview[viewNum],(room_height /2)-hview/2,64)
}
if time > 64 {act = 0; time = 0;audio_play_sound(sndCherry,1,0);}
break;
case 2:
if act = 1// and view_wview[0] != wview and view_hview[0] != hview
{
time += 1;
if instance_exists(objPlayer)
{
x = objPlayer.x
y = objPlayer.y
}
view_wview[viewNum] = EaseInSine(time,view_wview[0],wview,64)
view_hview[viewNum] = EaseInSine(time,view_hview[0],hview,64)
view_xview[viewNum] = EaseInSine(time,view_xview[0],(room_width /2)-wview/2,64)
view_yview[viewNum] = EaseInSine(time,view_yview[0],(room_height /2)-hview/2,64)
//view_xview[0] = EaseInSine(time,view_xview[0],view_xview[1],64) - view_xview[0]
//view_yview[0] = EaseInSine(time,view_yview[0],view_yview[1],64) - view_yview[0]
if time > 64 {act = 0; time = 0;}
}
break;
case 3:
if act = 1// and view_wview[0] != wview and view_hview[0] != hview
{
time += 1;
view_wview[viewNum] = EaseInSine(time,view_wview[viewNum],wview,64)
view_hview[viewNum] = EaseInSine(time,view_hview[viewNum],hview,64)
//view_xview[0] = EaseInSine(time,view_xview[0],wview,64)
///view_yview[0] = EaseInSine(time,view_yview[0],hview,64)
view_xview[viewNum] = EaseInSine(time,view_xview[viewNum],(room_width /2)-wview/2,64)
view_yview[viewNum] = EaseInSine(time,view_yview[viewNum],(room_height /2)-hview/2,64)
}
if time > 64 {act = 0; time = 0;}
break;
}
//if place_meeting(x,y,objPlayer)
//{
//act = 1;
//}
// Shake block
//view_xview[1] += view_xview[0] - view_xview[1]
//view_yview[1] += view_yview[0] - view_yview[1]
GML:
// Shake block
view_xview[1] += random_range(-shake,shake) - view_xview[0]
view_yview[1] += random_range(-shake,shake) - view_yview[0]
shake *= -0.9;
How i do correctly camera return after shaking? Without the strange shifting that is shown in the second video
I mean, I know that's the reason, but how do I get it to work right?