- darrenc182
- Posts: 6
- Joined:
Creating a Storyboard using C++
I am new to NoesisGUI and I am trying to create a storyboard using pure C++. I need this storyboard to start animating based on what may occur in-game so I either need to be able to trigger a storyboard defined in XAML or start one created in C++. I have tried to create a storyboard for this purpose in XAML, but I keep getting unhandled exception errors so I am trying to do it in C++ now. The code below also gives me an unhandled exception when I try running it:
I get the unhandled exception error on the last line (pStoryboard.GetChildren()->Add(&anim);)
I am using version 1.2.3 (r5440) and have been trying some of the code snippets in the forum, but I believe that the code in those snippets are old with depreciated syntax. Is there something I am doing wrong? Any and all help will be greatly appreciated and I thank you in advance.
Code: Select all
Noesis::Gui::DoubleAnimation anim=Noesis::Gui::DoubleAnimation();
anim.SetFrom(1.0f);
anim.SetTo(0.0f);
anim.SetDuration(Noesis::Gui::TimeSpan(0, 0, 0, 0, 500));
Noesis::Storyboard::SetTarget(&anim, m_cCanvas);
Noesis::Storyboard::SetTargetProperty(&anim, &Noesis::Gui::PropertyPath("Opacity"));
Noesis::Gui::Storyboard pStoryboard = Noesis::Gui::Storyboard();
pStoryboard.GetChildren()->Add(&anim);
I am using version 1.2.3 (r5440) and have been trying some of the code snippets in the forum, but I believe that the code in those snippets are old with depreciated syntax. Is there something I am doing wrong? Any and all help will be greatly appreciated and I thank you in advance.
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Creating a Storyboard using C++
Hi,
In NoesisGUI (almost) all classes follow a ref counted life-cycle and are meant to be used along with smart pointers.
Your code should be written this way:
In NoesisGUI (almost) all classes follow a ref counted life-cycle and are meant to be used along with smart pointers.
Your code should be written this way:
Code: Select all
Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();
anim->SetFrom(1.0f);
anim->SetTo(0.0f);
anim->SetDuration(Noesis::Gui::TimeSpan(0, 0, 0, 0, 500));
Noesis::Storyboard::SetTarget(anim.GetPtr(), m_cCanvas);
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Storyboard::SetTargetProperty(anim.GetPtr(), path.GetPtr());
Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();
pStoryboard->GetChildren()->Add(anim.GetPtr());
- darrenc182
- Posts: 6
- Joined:
Re: Creating a Storyboard using C++
Thanks for responding to me. I tried the code you presented, but I get the following error when trying to compile it:
error C2661: 'Noesis::Core::BaseObject::operator new' : no overloaded function takes 3 arguments
The syntax error points to this line of code:
Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();
I get the syntax error on these two lines of code as well:
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();
Do you know why I might be getting this error?
error C2661: 'Noesis::Core::BaseObject::operator new' : no overloaded function takes 3 arguments
The syntax error points to this line of code:
Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();
I get the syntax error on these two lines of code as well:
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();
Do you know why I might be getting this error?
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Creating a Storyboard using C++
What #includes do you have in your .cpp?
I think it could be a problem of not including the class definitions for DoubleAnimation, PropertyPath and Storyboard;
With version 1.2.3 you can use:
This header file includes all the class definitions of NoesisGUI, so it is best used with precompiled headers.
I think it could be a problem of not including the class definitions for DoubleAnimation, PropertyPath and Storyboard;
With version 1.2.3 you can use:
Code: Select all
#include <NoesisGUI.h>
- darrenc182
- Posts: 6
- Joined:
Re: Creating a Storyboard using C++
I had both Noesis.h and NoesisGUI.h included. I removed the Noesis.h header file, but I still get the error. I had some memory leak definitions, but I disabled them and now I am not getting those errors. I am getting an unhandled exception at this line:
pStoryboard->GetChildren()->Add(anim.GetPtr());
I am using MFC for this particular project because it is an editor. Below is an update to the code I am using:
pStoryboard->GetChildren()->Add(anim.GetPtr());
I am using MFC for this particular project because it is an editor. Below is an update to the code I am using:
Code: Select all
m_cCanvas = xaml->FindName<Noesis::Gui::Canvas>("StaminaBars6");
Noesis::Core::Ptr<Noesis::Gui::DoubleAnimation> anim = *new Noesis::Gui::DoubleAnimation();
anim->SetFrom(1.0f);
anim->SetTo(0.0f);
anim->SetDuration(Noesis::Gui::TimeSpan(0, 0, 0, 0, 500));
Noesis::Storyboard::SetTarget(anim.GetPtr(), m_cCanvas);
Noesis::Core::Ptr<Noesis::Gui::PropertyPath> path = *new Noesis::Gui::PropertyPath("Opacity");
Noesis::Storyboard::SetTargetProperty(anim.GetPtr(), path.GetPtr());
Noesis::Core::Ptr<Noesis::Gui::Storyboard> pStoryboard = *new Noesis::Gui::Storyboard();
pStoryboard->GetChildren()->Add(anim.GetPtr());
-
sfernandez
Site Admin
- Posts: 3184
- Joined:
Re: Creating a Storyboard using C++
Could you please generate a crash dump and attach it here, so we can debug what is happening?
Re: Creating a Storyboard using C++
You can generate a minidump within Visual Studio, on the Debug menu, click Save Dump As. You must do this whenever you get the unhandled exception dialog. Please, file a report and attach the dump there.
Is the error handler you pass to Noesis::GUI::InitDirectX9 being invoked at all? What kind of unhandled exception are you getting? Access violation?
Thanks for your patience.
Is the error handler you pass to Noesis::GUI::InitDirectX9 being invoked at all? What kind of unhandled exception are you getting? Access violation?
Thanks for your patience.
- darrenc182
- Posts: 6
- Joined:
Re: Creating a Storyboard using C++
Thanks for getting back to me. I am getting an access violation unhandled exception. I am using OpenGL and the Error Handler is not being called at all. I filed a report and included the dump file.
Re: Creating a Storyboard using C++
Thanks for the report!
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 8 guests