Animating the UI

Started by
-1 comments, last by Guns Akimbo 14 years, 11 months ago
Hi all, I would like UI components in my game to be animated... eg: * When my game switches to split screen mode i want the existing viewport to gradually shrink while the second gradually grows to fill the void. * When i show text I want it to fade in and then out. etc, etc. What would be the best method for such a thing? currently I'm thinking along the lines of: 1) Each UI component inherits from an AnimatibleUIElement class that has an update() method and public: targetTime, width, targetWidth, height, targetHeight, alpha and targetAlpha (or functions to act as getters/setters for those fields)... So you could create a textbox with alpha = 0.0, targetAlpha = 1.0, targetTime = 1000(ms) and call its update method during the gameloops update; which would increment/decrement each value towards its corresponding target until it hits it? or 2) During the games update loop set the relevant value of the required object (e.g textbox.alpha) to be = to a variable float. Have an object (say: uiAnimation) that contains a targetNumber, targetTime, a pointer to that float and an update() method that increments/decrements the value it points to over the course of uiAnimations target time. Store all those uiAnimation objects (or pointers to them) inside a vector and loop through them and call update() during the main games update method? or are there conventional ways of doing this? Cheers.

This topic is closed to new replies.

Advertisement