|
Animate Panels^^
#303814
01/02/10 14:53
01/02/10 14:53
|
Joined: Nov 2007
Posts: 2,568 Germany, BW, Stuttgart
MasterQ32
OP
Expert
|
OP
Expert
Joined: Nov 2007
Posts: 2,568
Germany, BW, Stuttgart
|
To animate an Panel use this simple 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: 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.
|
|
|
Re: Animate Panels^^
[Re: Puppeteer]
#303865
01/03/10 12:24
01/03/10 12:24
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
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
Expert
|
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.
|
|
|
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
Expert
|
Expert
Joined: Jan 2007
Posts: 2,247
Deutsch Niedersachsen
|
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.
|
|
|
Re: Animate Panels^^
[Re: Puppeteer]
#304007
01/04/10 13:01
01/04/10 13:01
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
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
Expert
|
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
#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.
|
|
|
Re: Animate Panels^^
[Re: Puppeteer]
#304038
01/04/10 17:10
01/04/10 17:10
|
Joined: Jun 2006
Posts: 2,640 Earth
Germanunkol
Expert
|
Expert
Joined: Jun 2006
Posts: 2,640
Earth
|
thanks for that if we end up animating the buttons i may use this..
~"I never let school interfere with my education"~ -Mark Twain
|
|
|
|