|
2 registered members (Quad, AndrewAMD),
1,007
guests, and 6
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Adjusting size / Animating Sprite entity
#259747
04/07/09 13:23
04/07/09 13:23
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
Hi,
just two simple questions this time, regarding a sprite entity created with ent_create.
1) I want the sprite to continuously increase it's scale_x and scale_y value and then decrease it again in a fluent animation. However, I tried to do so in a while-loop, incresing/decreasing scale_x and scale_y by 10% each frame (using wait(1) during each iteration). The result was... enormously laggy. The sprite shows up and it's scale "jumps" from about 10% to 50% and then to 100%... Why is that? Unfortunately I can't allow the process to take more than 5-10 frames, it has to work FAST, so I can't add 0.0001 to scale_x each frame which would produce a fluent animation I guess.
2) I know that there is a property for sprite-entitys which disables them to orientate themselves towards the camera. Right now, the sprite is always faced towards the cam, but I don't want that. I just haven't been able to figure out what the property was named, even when using the online manual... someone's got a hint for me here? Normally, I would simply assign a rotate-value other than 0 to the modell in WED, but since this one is created by ent_create during runtime, that's not possible.
Last edited by Alan; 04/07/09 13:24.
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: Alan]
#259842
04/07/09 23:45
04/07/09 23:45
|
Joined: Apr 2006
Posts: 737 Ottawa, Canada
Ottawa
User
|
User
Joined: Apr 2006
Posts: 737
Ottawa, Canada
|
Hi! 2) give your sprite a pan/tilt or roll orientation, this will stop it from following the camera. something like : vec_set (my.pan, vector(0.1,0,0)); Ottawa 
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: Ottawa]
#259857
04/08/09 00:41
04/08/09 00:41
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Ottawa has is for the sprite camera facing issue. (Look under "Pan, Tilt and Roll" in the manual).
Sprites should scale smoothly without a hitch, Im sure Ive done to myself at some point. Can we see the action/loop that does the scaling?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: EvilSOB]
#259955
04/08/09 11:21
04/08/09 11:21
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
Hi, the second problem (facing/not facing the camera) is solved, thanks to Ottawa. However, setting just the pan-angle to a non-zero value wasn't enough - the remaining two angles were still faing the camera. You actually have to set pan, tilt AND roll to non-zero values to make this work. As for the first issue, here's my function:
[...]
//some initialisiation-stuff is done here
define iterator, Skill1;
// set the initial size equal to 10% of the original size
my.scale_x = 0.1;
my.scale_y = 0.1;
// increase the sprite's size
my.iterator = 0;
while( my.iterator < 6)
{
my.scale_x += 0.2;
my.scale_y += 0.2;
my.iterator = my.iterator +1;
wait(3); // wait(1) looked terrible so I tried a higher value here
}
decrease the sprite's size (at a slower rate than it was increased previously)
my.iterator = 0;
while (my.iterator <= 10)
{
my.scale_x -= 0.1;
my.scale_y -= 0.1;
my.iterator += 1;
wait(3);
}
wait(3);
ent_remove(me);
Basically a simple code. But the result is somewhat strange. The sprite actually "flashes", so it appears, disappears for a frame or something, then again appears with an increased/decreased size and so on... doesn't look very fluent...
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: Alan]
#259964
04/08/09 11:49
04/08/09 11:49
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Nothing wrong with this code. Tested and looks fine to me.
Unless theres something else in application thats killing the framerate... Maybe the image itself? Is it BIG? Whats its size in megabytes? Otherwise I cant think of anything.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: EvilSOB]
#259968
04/08/09 12:04
04/08/09 12:04
|
Joined: Oct 2007
Posts: 306 Austria
Alan
OP
Senior Member
|
OP
Senior Member
Joined: Oct 2007
Posts: 306
Austria
|
I don't think that anything kills the framerate. All other processes work fine, it's just the animation which is laggy. The Picture itself has just slightly more than 4KB so that CAN'T be the reason.
The reason why I need this function is the following:
I want to make a small pinball-like game like the "Space Cadet", included in various windows-versions. My ball is a sphere-entity and it creates particles at its origin which decrease their size automatically as the ball moves, but maintain their position, creating a "meteor-effect" which works just fine. Now the sprite comes into play. If you've ever watched an episode of the "DragonBall Z"-anime you'll know what i mean: waves of energy are created in front of a flying object, increasing their size, the object flies through and then they decrease their size again once the object has passed the ring's position. And since the rings mustn't face the camera but have to be orientated along the object's movement-vector instead, the use of Particles for the rings was impossible. Therefore I used the "ent_create" statement, creating a ring-sprite every 10 frames in front of my ball. The rings getting bigger and smaller again are supposed to roughly outline the particles of the ball's "meteor-effect". But it just doesn't look the way I want it to do, the rings seem to pop up and disappear again at their will >.<
If it helps I could post the whole game-source-code in here, it's not THAT long up to now anyway.
Last edited by Alan; 04/08/09 12:04.
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: Alan]
#259999
04/08/09 14:03
04/08/09 14:03
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Lets concentrate on the image first. If the framerate was bad enough to affect the scaling times, it would be very noticable everywhere else.
Try saving the image in other formats. BMP, JPG, TGA, DDS, PNG, and see if any of them makes a difference(even if its not a fix). And is there any way you can upload the image itself?
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: Adjusting size / Animating Sprite entity
[Re: Alan]
#260163
04/09/09 08:19
04/09/09 08:19
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
After a bit of playing, Ive simplified and speeded you code a bit. That was just co-incidental while "smoothing" the animations. It now adjusts the scale once EVERY frame to improve smoothness. Give it a try and see what you think. I did notice that the ring, having a transparent center, does give the appearance of being a bit "jerky" even when smooth steps in scale are taken. If its still no good, let me know as Im thinking on a math to make the scale grow logarithmically, (starts slow then grows quicker as it expands), it may improve the look. May look more complex though. If you needed the frame values stored in skill1, TRY to go without temporarily. If something else was changing skill1, that would explain un-expected vanishing, and odd scaling etc. If you cant go without, pick another skill number in case of the above. Let me know how it goes... Also, any questions on the code I changed stir your brain, ask and all shall be revealed.
//some initialisiation-stuff is done here
// set the initial size equal to 10% of the original size
my.scale_x = my.scale_y = 0.1;
// increase the sprite's size
var c; for(c=0; c<15; c++) //15 is number of frames, change in all parts of loop if changing.
{ my.scale_x = my.scale_y += (1.0)/15;
wait(1); }
my.scale_x = my.scale_y = 1;
//decrease the sprite's size (at a slower rate than it was increased previously)
var c; for(c=0; c<30; c++) //30 is number of frames, change in all parts of loop if changing.
{ my.scale_x = my.scale_y -= (1.0)/30;
wait(1); }
my.scale_x = my.scale_y = 0.1;
wait(3);
ent_remove(me);
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|