Game Development Community

Biiiiiiiind Action: Zoooooom

by Zilla · in Torque X 2D · 08/02/2008 (1:33 pm) · 2 replies

I created a zoom function that works fine.
Now I wanted to do this:
As long as I hold the X key, the zooming should continue.
I remember that I should use BindAction for this.

I added:
inputMap.BindAction(keyboardId, (int)Keys.X, _ZoomOutButtonPressed); //ZoomOut

And just after the protected void _setupInputMap() function:

protected virtual void _ZoomOutButtonPressed(float val)
        {
            if (val == 1.0f)
            {
                camera = TorqueObjectDatabase.Instance.FindObject<T2DSceneCamera>("Camera");
                camera.Extent += deltaZoom;                                
            }
        }

It zooms, but not continuously: I have to hit the X button again and again to zoom in deltaZoom steps.

#1
08/03/2008 (10:52 am)
Zilla, replace BindAction with BindCommand... The difference is that BindAction fires a single event, whereas, BindCommand calls a begin method and an end method. Your ZoomOutButtonPressed method can be the begin method and maybe set the end method to null. I think that will do it - your method should just be called continuously until you release the X button.

John K.
#2
08/03/2008 (12:25 pm)
It didn't work. The method is called only once.

I found the thread that I remembered:
www.garagegames.com/mg/forums/result.thread.php?qt=68333

Doesn't it say something different?