Gamestudio Links
Zorro Links
Newest Posts
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Animate Panels^^ #303814
01/02/10 14:53
01/02/10 14:53
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline OP
Expert
MasterQ32  Offline OP
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
To animate an Panel use this simple code:
Code:
BMAP* animated_sprite = "explo+7.png"; // Here your file
var animation_offset = 0;

PANEL* panel_animate = 
{
	pos_x = 10;
	pos_y = 10;
	window(0,0,180,180,animated_sprite,animation_offset,0); // Replace 180,180 with the size of one sprite
	flags = SHOW;
}

function animate_panel() // Run to start animation
{
	int iWidth = bmap_width(animated_sprite);
	int iHeight = bmap_height(animated_sprite);
	while(1)
	{
		animation_offset += iHeight;
		animation_offset %= iWidth;
		wait(-0.05); // Animation speed
	}
}


The testing image:


Quote:

New code:
The code configures the animate_panel() to right sprite size and number.
You must only set the sprite size in the window definition (180,180) in panel_animate. Run animate_panel() to start the animation.


Last edited by Richi007; 01/03/10 13:13.

Visit my site: www.masterq32.de
Re: Animate Panels^^ [Re: MasterQ32] #303826
01/02/10 17:38
01/02/10 17:38
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Puppeteer Offline
Expert
Puppeteer  Offline
Expert

Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
You made a mistake.
Instead of camera_noise it has to be animation offset wink


Formally known as Omega
Avatar randomness by Quadraxas & Blade
http://omegapuppeteer.mybrute.com
Re: Animate Panels^^ [Re: Puppeteer] #303865
01/03/10 12:24
01/03/10 12:24
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
This is great code! We were actually thinking about animating a panel the other day, for our project.

Problem is, we'd like to animate a button on a panel, not a panel...


~"I never let school interfere with my education"~
-Mark Twain
Re: Animate Panels^^ [Re: Germanunkol] #303867
01/03/10 12:39
01/03/10 12:39
Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
Espér Offline
Expert
Espér  Offline
Expert

Joined: Mar 2008
Posts: 2,247
Baden Württemberg, Germany
button animations will come in the future with a A7 version *hope*

Hmm..The image has a "+4" in his name..
So, why not change the function to use a parameter given variable and the bitmap, to readout the bitmap +N and use it instead of hand-manipulating the 100/400?


but the codeis a good start.. perhaps i can do such a namereadout by myself ^^

Last edited by Espér; 01/03/10 12:40.

Selling my Acknex Engine Editions (A7 Com & A8 Pro):
>> click here if you are interested <<
Re: Animate Panels^^ [Re: Espér] #303871
01/03/10 13:14
01/03/10 13:14
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
MasterQ32 Offline OP
Expert
MasterQ32  Offline OP
Expert

Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
I changed the code so that it recognizes the amount of sprites


Visit my site: www.masterq32.de
Re: Animate Panels^^ [Re: Germanunkol] #303888
01/03/10 16:14
01/03/10 16:14
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Puppeteer Offline
Expert
Puppeteer  Offline
Expert

Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Originally Posted By: Germanunkol
This is great code! We were actually thinking about animating a panel the other day, for our project.

Problem is, we'd like to animate a button on a panel, not a panel...

This soooo easy.
You should know that.
I use a transparent button and animate a window beneath it so just make it like this;

panel bla
{
window(blabla)
button(alphachannelimagewithsizeofyourwindow,blabla)
etc.

EDIT:
@ Richi:
Your code will only work if you use quadratic patterns.

Last edited by Puppeteer; 01/03/10 16:18.

Formally known as Omega
Avatar randomness by Quadraxas & Blade
http://omegapuppeteer.mybrute.com
Re: Animate Panels^^ [Re: Puppeteer] #304007
01/04/10 13:01
01/04/10 13:01
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
puppeteer, I do know multiple ways of animating a button (though yours was one that I didn't know of yet and sounds very interesting). Problem is that all my buttons are created at runtime and dynamically, so it would be more work than we'd get out of it. Of course it can be done, but without a "animated-button" element in A7 I won't bother, it's not worth the trouble since we haven't even made the bmaps yet.

Also, I can't see how to highlight a button without more additional code when hovering over it with the mouse, using your method. I may rather update the button using pan_setbmap in a loop.
That being said, I'll keep your method in mind if I run across a situation where I really need an animated button, thanks!

Last edited by Germanunkol; 01/04/10 13:03.

~"I never let school interfere with my education"~
-Mark Twain
Re: Animate Panels^^ [Re: Germanunkol] #304033
01/04/10 16:46
01/04/10 16:46
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
Puppeteer Offline
Expert
Puppeteer  Offline
Expert

Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
This is easy too.
I made an example which works with an infinite number of buttons.
Download here
Code:
#include <acknex.h>;

BMAP* b_button="button.tga";
BMAP* b_buttontrans="buttontrans.png";
BMAP* b_mousemap="arrow.pcx";

#define num_buttons 2
#define num_animationsteps 4
#define animationsize 200

var anivars[num_buttons];
var button_states[num_buttons];

void button_over(var button_num,PANEL* panel);

PANEL* buttonani=
{
	flags=SHOW;
	layer=1;
	pos_x=250;
	pos_y=250;
	window(0,0,200,100,b_button,anivars[0],0);
	button(0,0,b_buttontrans,NULL,NULL,NULL,button_over,button_over);
	window(0,250,200,100,b_button,anivars[1],0);
	button(0,250,b_buttontrans,NULL,NULL,NULL,button_over,button_over);
}

void button_over(var button_num,PANEL* panel)
{
	if(event_type==EVENT_RELEASE)
	{
		button_states[button_num-1]=0;
	}
	else
	if(event_type==EVENT_TOUCH)
	{
		button_states[button_num-1]=1;//highlight
	}
}

void handlebuttons_startup()
{
	var i,temp_vars[num_buttons];
	while(1)
	{
		for(i=0;i<num_buttons;i++)
		{
			if(button_states[i]==1)
			{
				anivars[i]=animationsize*num_animationsteps;
			}
			else
			{
				temp_vars[i]=cycle(temp_vars[i]+time_step*0.25,0,num_animationsteps);
				anivars[i]=integer(temp_vars[i])*animationsize;
			}
		}
		wait(1);
	}
}

void main()
{
	video_screen=2;
	video_mode=10;
	wait(1);
	mouse_mode=2;
	mouse_map=b_mousemap;
	while(!key_esc)
	{
		mouse_pos.x=mouse_cursor.x;
		mouse_pos.y=mouse_cursor.y;
		wait(1);
	}
}



Last edited by Puppeteer; 01/04/10 16:46.

Formally known as Omega
Avatar randomness by Quadraxas & Blade
http://omegapuppeteer.mybrute.com
Re: Animate Panels^^ [Re: Puppeteer] #304038
01/04/10 17:10
01/04/10 17:10
Joined: Jun 2006
Posts: 2,640
Earth
Germanunkol Offline
Expert
Germanunkol  Offline
Expert

Joined: Jun 2006
Posts: 2,640
Earth
thanks for that laugh
if we end up animating the buttons i may use this..


~"I never let school interfere with my education"~
-Mark Twain
Re: Animate Panels^^ [Re: Germanunkol] #305450
01/14/10 20:36
01/14/10 20:36
Joined: Jul 2004
Posts: 1,710
MMike Offline
Serious User
MMike  Offline
Serious User

Joined: Jul 2004
Posts: 1,710
tis a shame that this is restricted to .. a max length of the sprite, because if i want a smooth efect thats uses bigger opanels, i will go around 5000X2000 or something which gives an error EHHE,
Even trying to multiline sprite..

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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