Sime0647
Topic Author
Posts: 3
Joined: 07 Jul 2022, 04:26

C++ Usage

25 Jul 2022, 20:32

Hi, I have downloaded and integrated Noesis in my custom engine. I have been checking the Documentation and the C++ Examples, but I can't find tutorials like the "Common Tutorials" but for C++, like an equivalent that shows you how to do Animations, Render Shapes, etc., but all in C++. I want to try and create a more simple version of the 3D Menu example but from scratch, without a XAML or the Application Framework.
Where can I find some C++ tutorials/examples that shows you how to create a menu like the 3D menu example?
I've created some buttons, text and canvas, but I don't know where to look for animations, change between views (for menu changing when a button is pressed) and upload images.

I hope you can help me.
 
User avatar
jsantos
Site Admin
Posts: 4823
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ Usage

26 Jul 2022, 09:24

There is no specific documentation for that part. And although this should be straightforward most of the times following the documentation in the C++ headers, don't hesitate to request for help here for specific things. I am adding an internal task here to create a tutorial about this, but this is going to be low priority for now. Also, our API is very similar to C# WPF, so you will find a lot of references and documentation on the internet that probably will be compatible (or almost) with Noesis.
 
Sime0647
Topic Author
Posts: 3
Joined: 07 Jul 2022, 04:26

Re: C++ Usage

27 Jul 2022, 21:47

I see... Thanks for consider the documentation!
To what C++ headers do you refer? The wathever thing I want to do headers?
And Thanks to your reply, I found this animation tutorial in the Microsoft documentation, it is pretty much the same as Noesis! But now I will take your word about ask about specific things.
I have followed the tutorial but the animation is not working, here is the code I wrote:
 
 Ptr<Canvas> g_pMainCanvas = *new Canvas();
 Ptr<TextBlock> g_pTitleText = *new TextBlock;
 Ptr<Storyboard> g_pStoryboard = *new Storyboard();
 Ptr<DoubleAnimation> g_pDoubleAnim = *new DoubleAnimation();

  //The Text is what I want to animate.
  g_pTitleText->SetText("My New Game");
  g_pTitleText->SetFontSize(100.0f);
  g_pTitleText->SetName("TitleName");
  
  //Animation configuration.
  g_pDoubleAnim->SetDuration(Duration(TimeSpan(0, 0, 3)));
  g_pDoubleAnim->SetFrom(1.0f);
  g_pDoubleAnim->SetTo(0.0f);
  g_pDoubleAnim->SetRepeatBehavior(RepeatBehavior::Forever());
  g_pDoubleAnim->SetAutoReverse(true);
  
  //Storyboard cofiguration.
   g_pStoryboard->GetChildren()->Add(g_pDoubleAnim);
  g_pStoryboard->SetTargetName(g_pDoubleAnim, g_pTitleText->GetName());
  g_pStoryboard->SetTargetProperty(g_pDoubleAnim, new PropertyPath(g_pTitleText->OpacityProperty));
  
  g_pMainCanvas->SetWidth(width);
  g_pMainCanvas->SetHeight(height);
  g_pMainCanvas->GetChildren()->Add(g_pTitleText);
And in the event that triggers the animation I wrote this:
void setConfigMenu(Noesis::BaseComponent* obj, const Noesis::RoutedEventArgs& args)
{
  g_pStoryboard->Begin();
}
The Canvas has a solid color background and a view is created from the canvas. A button triggers the event function and works fine, it's just the animation.
Also, I saw in the XAML tutorial that a BeginStoryboard is used, that need to be used in code too?

I hope you can help me again.
Thanks!
 
User avatar
sfernandez
Site Admin
Posts: 3363
Joined: 22 Dec 2011, 19:20

Re: C++ Usage

28 Jul 2022, 11:52

Hi, when creating storyboards in code you have to specify a target to fire the animation. The target is used to search for the namescope required to resolve the target names.
g_pStoryboard->Begin(g_pTitleText);
Apart from that I have to clarify that setting the Name property in code for an element is not enough to find it later using FindName. To correctly register an element in the namescope you have to call RegisterName from an element in the UI tree, something like this:
layoutRoot->RegisterName("TitleName", g_pTitleText);
An alternative to avoid using names is to specify the target object directly in the animation:
Storyboard::SetTarget(g_pDoubleAnim, g_pTitleText);
Hope this helps.

Who is online

Users browsing this forum: No registered users and 3 guests