Gamestudio Links
Zorro Links
Newest Posts
Converting History Data
by Erneto. 05/25/20 23:54
MT4/5 Bridge - Zero MQ
by Grat. 05/25/20 18:57
bug in parseData?
by Grat. 05/25/20 18:49
Train not save
by Grat. 05/25/20 18:36
CCT PhysX 2.0
by CodeMaster. 05/25/20 17:20
Trend Method on Financial Hackers
by jcl. 05/25/20 12:02
Negative prices?
by danatrader. 05/25/20 06:34
Is Zorro still viable?
by Grat. 05/25/20 05:12
AUM Magazine
Latest Screens
The Space Between
Pogostuck: Rage With Your Friends
Worst Case Z
AckCon'18 - Lotter vs the World 2 - Preview Release
Who's Online Now
2 registered members (AndrewAMD, Erneto), 523 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mike333, trader310, Onn, Dahn, happysun
18453 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Increasing Number Animation #479103
02/18/20 14:48
02/18/20 14:48
Joined: Jan 2012
Posts: 76
G
gamers Offline OP
Junior Member
gamers  Offline OP
Junior Member
G

Joined: Jan 2012
Posts: 76
Hi,
I want to prepare an increasing number animation for my GUI. For example, when the user wins a prize, how can I design the reward score as in the animation I shared on the link below?

The animation link is here: https://we.tl/t-sCdLe4Bjo3

Thank you for your support in advance.

Re: Increasing Number Animation [Re: gamers] #479104
02/18/20 15:25
02/18/20 15:25
Joined: May 2009
Posts: 5,241
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,241
Caucasus
Hey!

I would use digits and would increase variable (containing a number) slowly in a loop. This would result in something very similar to what you showed in the video!

Best regards.

Edit: this was actually pretty interesting to create (press space to add random value to the main score) grin
[Linked Image]
Code
var total_value = 5;
var value_to_add = 5;
var adding_speed = 0.025;

FONT *main_text_font = "Courier#80";
FONT *main_digit_font = "Courier#160";
FONT *add_digit_font = "Courier#64";

PANEL *main_digit_pan =
{
	digits(0, 0, "POINTS", main_text_font, 0, 0);
	digits(0, 160, "%.0f", main_digit_font, 1, total_value);
	flags = SHOW | CENTER_X | CENTER_Y;
}

PANEL *add_digit_pan = 
{
	digits(0, 0, "%+.0f", add_digit_font, 1, value_to_add);
	flags = SHOW | TRANSLUCENT | CENTER_X | CENTER_Y;
}

void add()
{
	value_to_add += 5 + integer(random(40));
}

void main()
{
	on_space = add;
	
	warn_level = 6;
	fps_max = 60;
	
	pan_setcolor(main_digit_pan, 1, 1, COLOR_GREY);
	vec_set(&add_digit_pan->blue, vector(0, 211, 255));
	
	var adding_timer = 0;
	
	while(!key_esc)
	{
		main_digit_pan->pos_x = screen_size.x / 2;
		main_digit_pan->pos_y = (screen_size.y / 2) - 160;
		
		add_digit_pan->pos_x = screen_size.x / 2;
		add_digit_pan->pos_y = (screen_size.y / 2) + 128;
		
		if(value_to_add > 0)
		{
			adding_timer += time_frame / 16;
			if(adding_timer >= adding_speed)
			{
				total_value += 1;
				value_to_add -= 1;
				adding_timer -= adding_speed;
			}
			
			add_digit_pan->alpha = 100;
		}
		
		if(value_to_add <= 0)
		{
			add_digit_pan->alpha -= 25 * time_step;
		}
		
		wait(1);
	}
}

Last edited by 3run; 02/19/20 14:39.

Looking for free stuff?? Take a look here: http://badcom.at.ua
Re: Increasing Number Animation [Re: gamers] #479105
02/18/20 15:31
02/18/20 15:31
Joined: Oct 2008
Posts: 671
Germany
Ayumi Offline
User
Ayumi  Offline
User

Joined: Oct 2008
Posts: 671
Germany
Hi, you can use a Background Image in a Panel with variable to stay dynamic.
The "+63" can be a String or a TEXT* Object, using str_for_num.

Code

var count 0;
PANEL* pan = NULL;	
FONT* font = NULL;

void Test()
{
	int i;
	
	if(!font) {
		font = font_create("Arial#12");		
	}
	
	if(!pan) 
	{
		pan = pan_create(NULL, 1);	
		pan.flags |= SHOW;
		pan.bmap = bmap_create("YourBackgroundImg.tga");
			
		pan_setdigits(pan, 0,10,10, "Count: %d", font, 1, count);	
	}


	// ...
	
	count = 10;
	
	for(i=0; i < 20; i++);
	{
		count++;
	}
	
      //ptr_remove(font);
      // font = NULL;

     //ptr_remove(pan.bmap);
     // pan.bmap = NULL;

     //ptr_remove(pan);
     // pan = NULL;
}


Re: Increasing Number Animation [Re: gamers] #479108
02/19/20 07:16
02/19/20 07:16
Joined: Jan 2012
Posts: 76
G
gamers Offline OP
Junior Member
gamers  Offline OP
Junior Member
G

Joined: Jan 2012
Posts: 76
Wow, thanks for your support. That was amazing solution.
@3run & @Ayumi


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1