Game Development Community

Components Communicate with GUIControl

by kinleong · in Torque X 2D · 07/18/2009 (2:22 am) · 2 replies

Hi all,

Here is my situation. I have a T2DSceneObject with T2dCollisionComponent. I have delegate a method for the OnCollision. It is a small sparking particle effect. Now, I added a GUIControl to the screen which is a GUIBitmap. I would like to change the picture of the GUIBitmap during the T2dSceneObject is collided. How can I achieve it? Thanks a lot.

#1
07/18/2009 (12:46 pm)
In your OnCollision handler, add the following code:

GUIBitmap gb = TorqueObjectDatabase.Instance.FindObject<GUIBitmap>("myBitmapObject");
gb.Bitmap = @"data\images\nameOfImageToRender";

Ensure that you have the image in your Game\data\images folder and as included in the Content for your game.

Let me know if this doesn't work for you.
#2
07/19/2009 (1:31 am)
Thanks a lot. It works.