Game Development Community

How do i show a scope when i zoom in

by fire maker · in Torque Game Engine · 06/12/2007 (4:32 pm) · 2 replies

I know how to zoom in but when i zoom in i want to see a scope i know it is possible but i need code i can copy over if you could help it would be helpful thanks

#1
07/26/2007 (4:18 pm)
Just push a GuiBitmapCtrl onto the screen with a partially transparent scope image. And decrease the player's FOV. But make sure that the player's ZoomSpeed is not zero, or it will not have that nice zoom-in, zoom-out effect.
#2
07/26/2007 (4:32 pm)
Like this:

// Replace MaleAvatar with your player's avatar class.

MaleAvatar::onZoom(%this, %zoomDegree, %zoomSpeed)
{
        %this.SetZoomSpeed(%zoomSpeed);
        %this.SetFOV(%zoomDegree);
        ZoomScope.push();  // You will have to make a screen-sized GuiBitmapCtrl with a transparent scope image on it. It must be named ZoomScope, or this particular line of code will not work.
}

// Or you could use....

MaleAvatar::onZoom(%this, %zoomMultiple, %zoomSpeed)
{
        %this.SetZoomSpeed(%zoomSpeed);
        %fov = %this.GetFOV();
        %fov /= %zoomMultiple;
        %this.SetFOV(%fov);
        ZoomScope.push();  // See above sidenote.
}

// But either way, put in this afterwards...

MaleAvatar::onUnzoom(%this, %unzoomSpeed)
{
        %this.SetZoomSpeed(%unzoomSpeed);
        %this.SetDefaultFOV();
        ZoomScope.pop();  // See above sidenote.
}

// What these do basically is change the Field Of View to a different degree value, set the Field Of View 
// Adjustment rate slower, and create a bitmap image of a scope. The OpenGL vision distortion will take
// care of the fisheye effect.