Game Development Community

Rotate GUI Bitmap?

by Chris Jorgensen · in Torque Game Builder · 12/11/2006 (12:50 am) · 7 replies

Is there a way in script to control the rotation of a gui bitmap object?

#1
02/13/2007 (10:15 pm)
From everything I have seen, there is no provision to rotate a Gui control. The geometric model appears to be a rectangle. If you associate a bitmap with a Gui element, your Gui will respond to, say, mouse clicks, even in the places where the bitmap is transparent, as long as the user clicks inside the Gui's Extent (rectangle).

A t2dSceneObject, by contrast, has a highly developed geometric model, one which includes arbitrary rotations. Also, through the collision mechanism, a scene object's geometric model extends to any convex disc.

So a Gui control and a Scene Object are very different.

It would be interesting to consider what a Gui would be like if the geometric model of a Gui control were as complex as that of a scene object. Boggles the mind.

Oh, yes. I just thought of an exception: guiT2DObjectCtrl. I have never used it, but the docs seem to indicate that it might prove useful. Here is a synopsis:
Class Hierarchy:
  guiT2DObjectCtrl ->GuiButtonCtrl ->GuiButtonBaseCtrl ->GuiControl ->SimGroup ->SimSet ->SimObject ->
Member Fields:
  buttonType = "RadioButton"
  renderMargin = "0"
  sceneObject = ""
Tagged Fields:
Methods:
  getSceneObject() - returns displaying sceneobject id
  setCaption( string caption );
  setSceneObject( string object-id/name ) - Set the T2D sceneObject displayed in the control.
As you can see, it is a button, not a menu or a text control, or whatever.
#2
02/14/2007 (10:23 am)
Personally, were I to need rotating "guis", I would not use GUI objects, but use t2d objects instead. With the addition of t2dTextObject, you can re-implement all of the basic functionality of GUI's, but have the extra capabilities of t2dObjects as well (rotation, animation, easy shape changes, quite a bit of functionality).
#3
02/25/2009 (12:19 pm)
That's what I thought too Stephen, but with my game type, I ran into some issues (maybe you can help). Think of a Geometry Wars type of game. I have 2 "virtual analog joysticks" to control movement and shooting. I want those to be along the bottom of the screen. The camera is mounted to the player. How do I keep those 2 joysticks in the same place. If I subscribe to onUpdate calls and do a setPosition, they are "jittery" (best way I can describe it). I had an idea to create 2 mount points on the player, but wasn't thinking that when the player rotates, the mount points will too and subsequently the joysticks.

So, I'm in the process of just created GUI based joystick controls (based off some compass code I found in resources). Since this is for iPhone, I really don't have to worry about them "clicking" in the transparent parts of the round joystick (i.e. bounding box near the 4 corners) since it's their finger.

Sound fine or do you still think t2d objects are better in this situation and how would you do it?
#4
02/25/2009 (10:25 pm)
I just finished the GUI solution and it works great. If it ain't broke don't fix it right :-) Though I'd still be interested to hear your thoughts on a t2dobject solution (though I think I have an idea on how I would implement it.
#5
02/26/2009 (2:46 pm)
A two year old thread is born again! I'd say just make a dedicated sceneWindow for your GUI elements, if you want to use sprites (and other objs) for a GUI. Then make sure your objects are set to Immovable. That should be all you need to make rotating HUD elements. :)
#6
02/27/2009 (11:26 am)
Whoops, didn't even take a look at the date. My bad.
#7
02/27/2009 (11:33 am)
more for the interest of future explorers than anything, fwiw,
there are two TGE resources to add rotation to GuiBitmapCtrls:
this one (by me)
and this one by Phil Carlisle.