How do I create and add a Visual from Uno after the page is created?

Hi.

I’m building a 2D game engine that runs on Fuse.

I finished about 70% of my goals.

I’ve already implemented the part where I add and delete the Sprite Tree using < Each >.

I’m trying to change the implementation because I’m getting a bit slower when I add a Sprite.

Using the NativeModule
I created a new Visual and added it to other Visual Children.
Like this.

<JavaScript>
var a = NativeModule.MakeNewVisual();
NativeModule.AddVisualToOther(other, a);
</JavaScript>

When I do this, it works as intended.

<JavaScript>
var a = NativeModule.MakeNewVisual();
setTimeout( function() {
     NativeModule.AddVisualToOther(other, a);
}, 1000 );
</JavaScript>

And it works.

But if I create the Visual later, it fails.

<JavaScript>
setTimeout( function() {
     var a = NativeModule.MakeNewVisual();
     NativeModule.AddVisualToOther(other, a);
}, 1000 );
</JavaScript>

This will add the Visual to other.Children but nothing on the screen.
(It increases other.Children.Count )

 other.InvalidateLayout() 
 other.InvalidateVisual()

Not works.

I already know how to use < Each >.

However, I want to know how to create and add objects and display them properly with uno.

Thank you.

Hi,

Why do you want to manipulate Visuals with Uno? Is it purely for performance reasons?

You won’t get any better performance by doing that. If you want to display a lot of sprites fast, you need some form of sprite batching component. This is possble to write in Uno, we have some experimental code but productizing this is currently not in our roadmap.

Fuse is generally not reccommended for games that require a lot of moving elements. For that, you should use a game engine like Unity (https://unity3d.com/)

Thanks for the reply.
We are making games at game companies, and we also use dedicated game engines like Unity3D and Unreal.
However, the reason we focus on Fuse is because Fuse seems to be a good fit for creating Native apps with game-like capabilities.

So we’d like Fuse to be able to manage the components dynamically slightly more.
We have already implemented Fuse at the level of 2D Game Engine like Corona SDK or Gideros. I am very satisfied with the structure of fuse and OpenGL performance, and I think it has great potential.

The above problem is solved by using the < Deferred > statement in the < Each > statement. When you add a Sprite, there is a slight delay, but not a big problem. We will be very glad if it can be improved in the future update.

We think the boundaries between games and apps are becoming increasingly obscure. At that point, I think Fuse will show great strength.

Thank you.

It is definitely doable in Fuse, we have had the idea of a <SpriteBatch> component for a long time. However, there is currently not enough demand from our users/customers to make this a priority at this point.

If you are using Fuse in a commercial project and have special requirements, feel free to contact us (contact@fusetools.com) to discuss a custom support plan.

We have not tried to start the project yet, but we are making various attempts using Fuse. If audio support is the only thing that finishes, we are in a state where we can make enough commercial products. I have attached a video of the app I’m testing now.

We believe that Fuse’s support of game-like interactions is a strong advantage over its competitors.
Thanks to the Fuse team for making great products.

Any news about the 2d game engine? The demo is great

Bumping thread because of the awesome demo and interest in 2d game engine …