Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/25/26 19:13
ZorroGPT
by TipmyPip. 04/25/26 16:09
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
2 registered members (3run, 1 invisible), 3,648 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
valino, juergenwue, VladMak, Geir, ondrej
19209 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Adjusting size / Animating Sprite entity [Re: Alan] #260546
04/11/09 21:50
04/11/09 21:50
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
just convert my code to like c-script. "Here's one I prepared earlier..."
Code:
   
   // set the initial size equal to 10% of the original size
   my.scale_x = 0.1;	my.scale_y = my.scale_x;
   
   // increase the sprite's size
   var c=0; while(c<15)      //15 is number of frames, change in all parts of loop if changing.
   {  my.scale_x += (1.0)/15;	my.scale_y = my.scale_x;
      c += 1;     wait(1); 					}
   my.scale_x = 1;	my.scale_y = my.scale_x;   //*optional* set to exactly full size

   //decrease the sprite's size (at a slower rate than it was increased previously)
   c=0; while(c<30)      //15 is number of frames, change in all parts of loop if changing.
   {  my.scale_x -= (1.0)/30;	my.scale_y = my.scale_x;
      c += 1;     wait(1); 					}
   my.scale_x = 0.1;	my.scale_y = my.scale_x;   //*optional* set to exactly initial size
 
   wait(3);
   ent_remove(me);



"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Adjusting size / Animating Sprite entity [Re: EvilSOB] #260579
04/12/09 08:31
04/12/09 08:31
Joined: Oct 2007
Posts: 306
Austria
A
Alan Offline OP
Senior Member
Alan  Offline OP
Senior Member
A

Joined: Oct 2007
Posts: 306
Austria
Hi,

I just executed the program with your code - in the beginning I didn't see much difference in effect compared to my original code. The result still looked like this:

http://www.letsshareit.net/files/5/ring_2.bmp

Then I suddenly remembered that 15 frames (at 24 frames per second or even more) are less than one second display-time. So I increased the values a bit (100 frames for the increase-animation, 200 for the decrease-animation) - things already looked better, but still not quite what I wanted it to look like. After checking my code once again, this time knowing exactly that the animation-part itself was free of errors, I wondered whether the problems were caused by the function which actually calls the entire ring-function. So I exchanged that procedure so that a ring would appear every time I hit the "R"-Key on my keyboard - and that did it. My function just called the rings over and over again, WAY TOO FAST.
The action for my ball which serves as a kind of a "source" for the rings looked like this:

Code:
var ring_count = 0;

function create_ring()
{
 // your animation code is placed here along with some initialisation stuff
}


action ball_action()
[...]
ring_count += 1;
if ring_count = 10
{
  create_ring();
  ring_count = 0;
}
[..]
wait(1);


So a new ring was created every 10 frames. The result looked "laggy" but actually it was not slow but WAY too fast.

Problem solved, I think I can handle the rest (correcting the procedure which calls the ring_create) by myself.

Big thanx, EvilSOB! You really helped me out on this one!


Greetz!


Alan

Re: Adjusting size / Animating Sprite entity [Re: Alan] #260583
04/12/09 08:56
04/12/09 08:56
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
No problem. Glad I could help.

Just one suggestion before I go if you dont object,
I would be inclined to use time_step instead of just '1' in your ring-count.
Code:
ring_count += time_step;
if(ring_count >= 10)   //probably need to find a new number for this though
This is because time_step auto-smooths timing issues relating to frame rates.
By using time_step, if the frame-rate drops, you'll still get X number of rings per second,
because the time_step changes size according to the approximate frame-rate.
But if you use just +1, then if the frame-rate drops, you'll get less rings per second,
because the +1 action doesnt get run as many times a second.

See what I mean?


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 2 1 2

Gamestudio download | 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