[Include] Textdraw Animations
#1


TEXTDRAW ANIMATIONS 1.1


With this include you can add a little more life to your textdraws:

Click here for a quick preview!

The effects include:

- Showing textdraws in a progressive way.
- Showing textdraws growing from 0 to x.
- Showing textdraws with a pulsating effect.


So, let's see how it's done...

First, you need to copy the .inc file to your includes folder and put inside your filterscript or gamemode:

pawn Код:
#include <TextDrawAnimations>
This effects are meant to be used with textdraws created inside an array called "T_Buffer" wich it's max length you can define by writing:

pawn Код:
#define MAX_BUFFER 100
You have to define it before including the file, so it should look like this:

pawn Код:
#define MAX_BUFFER 100
#include <a_samp>
#include <TextDrawAnimations>
If you don't define it, max size is 24.

Once you've done that, you need to create the textdraws wich you want to apply an effect to.

You can just set the buffer to 200 and create them all at once, or you can create them dinamically and have a smaller T_Buffer array size ( later i'll show you how you can call different T_Buffer values to show certain textdraws ).

pawn Код:
#define TEXTDRAWS_ANIMATION_0 0
#define TEXTDRAWS_ANIMATION_1 1

CreateDynamicTextdraws( index )
{
    switch( index )
    {
        case TEXTDRAWS_ANIMATION_0:
        {
            T_Buffer[0] = TextDrawCreate(320.000000, 130.000000, "You");
            TextDrawAlignment(T_Buffer[0], 2);
            TextDrawBackgroundColor(T_Buffer[0], 255);
            TextDrawFont(T_Buffer[0], 1);
            TextDrawLetterSize(T_Buffer[0], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[0], -16776961);
            TextDrawSetOutline(T_Buffer[0], 0);
            TextDrawSetProportional(T_Buffer[0], 1);
            TextDrawSetShadow(T_Buffer[0], 1);

            T_Buffer[1] = TextDrawCreate(320.000000, 160.000000, "Can");
            TextDrawAlignment(T_Buffer[1], 2);
            TextDrawBackgroundColor(T_Buffer[1], 255);
            TextDrawFont(T_Buffer[1], 1);
            TextDrawLetterSize(T_Buffer[1], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[1], -16776961);
            TextDrawSetOutline(T_Buffer[1], 0);
            TextDrawSetProportional(T_Buffer[1], 1);
            TextDrawSetShadow(T_Buffer[1], 1);

            T_Buffer[2] = TextDrawCreate(320.000000, 190.000000, "Animate");
            TextDrawAlignment(T_Buffer[2], 2);
            TextDrawBackgroundColor(T_Buffer[2], 255);
            TextDrawFont(T_Buffer[2], 1);
            TextDrawLetterSize(T_Buffer[2], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[2], -16776961);
            TextDrawSetOutline(T_Buffer[2], 0);
            TextDrawSetProportional(T_Buffer[2], 1);
            TextDrawSetShadow(T_Buffer[2], 1);

            T_Buffer[3] = TextDrawCreate(320.000000, 220.000000, "this text!");
            TextDrawAlignment(T_Buffer[3], 2);
            TextDrawBackgroundColor(T_Buffer[3], 255);
            TextDrawFont(T_Buffer[3], 1);
            TextDrawLetterSize(T_Buffer[3], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[3], -16776961);
            TextDrawSetOutline(T_Buffer[3], 0);
            TextDrawSetProportional(T_Buffer[3], 1);
            TextDrawSetShadow(T_Buffer[3], 1);
           
            T_Buffer[4] = TextDrawCreate(340.000000, 280.000000, "Or make it grow!!!");
            TextDrawAlignment(T_Buffer[4], 2);
            TextDrawBackgroundColor(T_Buffer[4], 255);
            TextDrawFont(T_Buffer[4], 1);
            TextDrawLetterSize(T_Buffer[4], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[4], -16711681);
            TextDrawSetOutline(T_Buffer[4], 0);
            TextDrawSetProportional(T_Buffer[4], 1);
            TextDrawSetShadow(T_Buffer[4], 1);
        }
               case TEXTDRAWS_ANIMATION_1:
        {
            T_Buffer[0] = TextDrawCreate(340.000000, 280.000000, "Another text with effect");
            TextDrawAlignment(T_Buffer[0], 2);
            TextDrawBackgroundColor(T_Buffer[0], 255);
            TextDrawFont(T_Buffer[0], 1);
            TextDrawLetterSize(T_Buffer[0], 1.300000, 4.000000);
            TextDrawColor(T_Buffer[0], -16711681);
            TextDrawSetOutline(T_Buffer[0], 0);
            TextDrawSetProportional(T_Buffer[0], 1);
            TextDrawSetShadow(T_Buffer[0], 1);
        }
    }
   
    return 1;
}
So before you apply an effect, you call CreateDynamicTextdraws( index ) to create the textdraw inside T_Buffer, wich is from where we're gonna read the values to show the textdraws later.

So, suppose you want to make the effects you saw on the video.

You create the textdraws first as explained, and then you use the Callback "OnAnimFinish" to control what happens after an effect ends:

pawn Код:
public OnAnimFinish( playerid, index )
{
    switch( index )
    {
        case TEXTDRAWS_ANIMATION_0:
        {
            TextDraw_Grow(playerid,TEXTDRAWS_ANIMATION_1,100,2500, 0, 4, 1.3, 4.0);
        }
        case TEXTDRAWS_ANIMATION_1:
        {
            TextDraw_Pulsate(playerid,TEXTDRAWS_ANIMATION_FINISH,10,100,0,4 );
        }
        case TEXTDRAWS_ANIMATION_FINISH:
        {
            TextDraw_Hide( playerid, 0, -1 );
        }
    }
   
    return 1;
}
And to start the magic, you can use a command like:

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/anm", cmdtext, true, 10) == 0)
    {      
        CreateDynamicTextdraws( TEXTDRAWS_ANIMATION_0 );
        TextDraw_FadeIn( playerid, TEXTDRAWS_ANIMATION_0, 100, 2000, 0, 4 );       
        return 1;
    }

    return 0;
}
And you're done!

Now let's see each function to know what they do:

TextDraw_Grow( playerid, index, anim_speed, duration, T_Buffer_min, T_Buffer_max, Float:max_x, Float:max_y );



This one makes the text grow from 0 to X
  • playerid: the player you want to show the textdraw to
  • index: this is the "index" which OnAnimFinish is gonna call after the animations finishes.
  • anim_speed: this is how fast the text should grow in milliseconds (the progressive size is calculated automatically).
  • duration: how much time before calling OnAnimFinish should pass after the animation finishes.
  • T_Buffer_min & max: this is to show certain textdraws. If you created 100 textdraws and only want to show from 17 to 25, then you need to put those numbers in there.
  • float:max_x & max_y: this is how far the textdraw will grow.
TextDraw_FadeIn(playerid,index,speed,duration,T_Bu ffer_min,T_Buffer_max)



This one makes textdraw appear one after another.
  • playerid, index, duration, T_buffer_min & max: same as before
  • speed: the speed at wich the textdraws will show in milliseconds. 1000
    means 1 textdraw every one second.
TextDraw_Pulsate( playerid, index, repetitions, speed, T_Buffer_min, T_Buffer_max )



This one creates a pulsating effect.
  • playerid, index, speed, T_Buffer_min, T_Buffer_max: same as before:
  • repetitions: how many times the text is gonna pulsate. Keep in mind that if you put "10" repetitions and the speed at "1000", that means the textdraw will show 5 times and hide 5 times.
TextDraw_Hide(playerid,T_Buffer_min,T_Buffer_max)

This function hides the textdraws from min to max. Set the max parameter to -1 and it will hide every textdraw inside T_Buffer.

StopTextDrawAnimations( playerid );

You can call this one to stop any animation or timer currently running.

And that's it!

Download from PASTEBIN:

- TextDrawAnimations.inc v1.1.
- Testit.pwn ( an example showing the basic stuff ).

Bugs fixed:

- Some variables where changed after they were used and could cause unwanted behaviour.

Other:

- I'll try to add more effects later.
- I added another define: PLY_MX wich equals to MAX_PLAYERS if not defined. This is to calculate the array size of the array called T_Stuff wich handles some player data.
- Don't try to use more than one effect at a time or it will mess up, because it only uses one timer. I'll do an update soon so you can use many effects at once.

Reply
#2

Really nice, gonna test this as soon as I get some time.
Reply
#3

Very nice job man, 3rep4u.
Reply
#4

Nice man
Reply
#5

It's awesome, great job ! +rep for you work.
Reply
#6

WTF!! 0_0
Its Damn COOL!!

+rep
Reply
#7

Btw looks nice. I will test it later and tell you if there some bugs.. Good work!
Reply
#8

thanks for this usefull release.
Reply
#9

Damn good work! TextDraw_Pulsate , im in love with this!
Reply
#10

nice !
Reply
#11

Very nice include! Well done!
Reply
#12

Nice ^

You gave me a idea for my new gamemode
Reply
#13

OMFG :O
REALLY AMAZING
I ENJOYED IT )) +good work
Reply
#14

Nice
Reply
#15

Very nice!
Reply
#16

x_O" it's coo , good job ;P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)