1.1.3 t2dScroller, setScrollPositionX/Y
by Jemand den es nicht gibt · in Torque Game Builder · 12/03/2006 (11:50 am) · 0 replies
I don't know if it is intended or not but setScrollPositionX/Y overrides the other coordinate with zero apparently. I was working on my parallax background manager and had the following code:
I was wondering why this doesn't work.. the backgrounds just wouldn't scroll! They did though if i controlled everything from console. Well, after I commented out setScrollPositionY it finally scrolled.. (scrollFactorY was 0 in my project on this one).
Well, I'm glad I found this one.. it should either be documented or fixed. :)
function ParallaxBackgroundManager::update(%this)
{
%cameraPositionX = getWord(sceneWindow2D.getCurrentCameraPosition(), 0);
%cameraPositionY = getWord(sceneWindow2D.getCurrentCameraPosition(), 1);
for(%i = 0; %i < %this.backgrounds.getCount(); %i++)
{
%currentScroller = %this.backgrounds.getObject(%i);
%currentScroller.setScrollPositionX(%cameraPositionX * %currentScroller.scrollFactorX);
%currentScroller.setScrollPositionY(%cameraPositionY * %currentScroller.scrollFactorY);
}
}I was wondering why this doesn't work.. the backgrounds just wouldn't scroll! They did though if i controlled everything from console. Well, after I commented out setScrollPositionY it finally scrolled.. (scrollFactorY was 0 in my project on this one).
Well, I'm glad I found this one.. it should either be documented or fixed. :)