Jump to content
  • Register Now

    Sign up and take advantage of the features of our community! Some forums are only accessible to our members!

Functions on timeline


Recommended Posts

Hey guys,

It was really a long ago I did any activity on a forum so I decided to release a small but usefull class.

This can be used to place functions you want to run on every frame for a period of time with a progress on a "timeline". This can be used for example to roll the yang up or down when changing it (a normal way and not creating threads or wtf others doing) or anything else when you animating something in code.

So add this 2 files (download link at the end of this post) to your project and go to PythonApplication.cpp and find the Process function.

Add this line after like OnUIUpdate();:

Timeline::GetInstance()->DoEvents();

 

You can add functions like (it's an example for the mentioned yang stuff):

            auto currentGold = rkPlayer.GetStatus(POINT_GOLD);
            auto goldChange = PointChange.value - currentGold;
            Timeline::GetInstance()->AddFunction(0.5f, 
                [currentGold, goldChange](float p)
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + (goldChange * p));
                },
                [currentGold, goldChange]()
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + goldChange);
                }
            );

Download: https://distraught.hu/download/m2dev/Timeline.rar

 

Good luck!

 

 

-----------------------

Oh and if you can't compile it because the compiler does not find ModernSingleton then here it is:

template<typename T>
struct ModernSingleton
{
    static T* GetInstance()
    {
        static T _instance;
        return &_instance;
    }
};

(just add it to like singleton.h)

Edited by Distraught (see edit history)
  • Love 3

AxgtRfG.png
C++ programmer at Gameloft

 

1331

Link to post
On 7/12/2020 at 8:31 PM, Distraught said:

Hey guys,

It was really a long ago I did any activity on a forum so I decided to release a small but usefull class.

This can be used to place functions you want to run on every frame for a period of time with a progress on a "timeline". This can be used for example to roll the yang up or down when changing it (a normal way and not creating threads or wtf others doing) or anything else when you animating something in code.

So add this 2 files (download link at the end of this post) to your project and go to PythonApplication.cpp and find the Process function.

Add this line after like OnUIUpdate();:

Timeline::GetInstance()->DoEvents();

 

You can add functions like (it's an example for the mentioned yang stuff):

            auto currentGold = rkPlayer.GetStatus(POINT_GOLD);
            auto goldChange = PointChange.value - currentGold;
            Timeline::GetInstance()->AddFunction(0.5f, 
                [currentGold, goldChange](float p)
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + (goldChange * p));
                },
                [currentGold, goldChange]()
                {
                    CPythonPlayer& rkPlayer = CPythonPlayer::Instance();
                    rkPlayer.SetStatus(POINT_GOLD, currentGold + goldChange);
                }
            );

Download: https://distraught.hu/download/m2dev/Timeline.rar

 

Good luck!

 

 

-----------------------

Oh and if you can't compile it because the compiler does not find ModernSingleton then here it is:

 

template<typename T>
struct ModernSingleton
{
    static T* GetInstance()
    {
        static T _instance;
        return &_instance;
    }
};

 

(just add it to like singleton.h)

where did you put the POINT_GOLD function ?

Edited by Mafuyu (see edit history)
Link to post

That was just an example, it's not a tutorial for that specific stuff.

But put it in CPythonNetworkStream::RecvPointChange in the if (PointChange.Type == POINT_GOLD) condition.

  • Love 1

AxgtRfG.png
C++ programmer at Gameloft

 

1331

Link to post
On 7/14/2020 at 4:56 PM, Distraught said:

That was just an example, it's not a tutorial for that specific stuff.

But put it in CPythonNetworkStream::RecvPointChange in the if (PointChange.Type == POINT_GOLD) condition.

yeah thats what i was trying but it didnt worked for me, it didnt change anything ingame.

can you show the full edit function how it would work? i tried some changes but no effect on it, so i dont know if i made mistaks or if the system doesnt work

Edited by Mafuyu (see edit history)
Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.