Jump to content
  • Advertisement
Sign in to follow this  
Guns Akimbo

Animating the UI

This topic is 3493 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!