Game Development Community

Mounting background to camera

by Walter K · in Torque Game Builder · 11/25/2006 (11:11 am) · 3 replies

Working off the MiniPlatformerTutorial, I'm trying to have a background (t2dScroller) that stays fixed relative to the camera. I've tried two approaches: (1) setting the background's position to the camera's position in the onUpdateScene() function, and (2) mounting the background to the player object with the same settings as the camera.

The first approach causes some noticeable redraw problems if the player object moves too fast, and the background will lag behind the camera. The second approach draws perfectly, with the huge exception that the background flips along with the player object when setFlip is called.

Anyone have a different approach to the problem?

#1
11/25/2006 (11:23 am)
To overcome the flip problem, in your function, you could dismount the background from the player, flip the player and then remount the background on to the player. You could also use the mount command and set '%inheritAttributes' to false. This means that the background will stick with the player but will not take into account if the player is flipped, enabled, visible or paused.

hth
#2
11/25/2006 (12:39 pm)
Ah ha. You, sir, are the bomb. Thank you.
#3
11/25/2006 (1:39 pm)
Your welcome :)