Question on Events

Mar 15, 2010 at 10:04 AM

Hi, Thanks for your amazing work. Is there any more comprehensive material for beginner?

Q1. I have a question on mouse event. There has been an example on Mouse Click Event, the mesh object was written in XAML file, and the xmal.cs file is used for Eventhander. However, in the other examples, it use a myGame.cs which inherited Game.cs to load 3D object rather than write it in MainPage.xmal. In this situation, how could I hander its event?

Q2. There are some sawtooth in the performance screen, is there any methods to improve its performance in code? Or it is mainly due to the ASE file? How many 3D Sphere objects does Balder support for most? Thanks a lot ~ :)

Mar 15, 2010 at 11:02 AM
Edited Mar 15, 2010 at 11:03 AM

Hi and thanks.

We're hard at work creating more tutorials and content to help people get started with Balder. One of the things that will come is a compiled help file with samples and full documentation.


The objects you load have the Mouse events exposed as regular CLR events, so you can simply do: 


myObject.MouseMove += new MouseEventHandler(YourEventHandler);




Could you elaborate? What do you mean by sawtooth?  Balders main performance bottleneck is drawing. So number of polygons/triangles in your scene will be the biggest performance hit. If your spheres has few polygons, you can add a bunch of spheres, that shouldn't really be the biggest issue. The upcoming release has some great improvements for performance - it is something we're working steadily on for every release. But at one point we will hit the limit of what is possible with Silverlight, but we're confident that there is still a few things that can be done get even more squeezed out of it.


Hope that was helpful.

Mar 15, 2010 at 11:25 AM

Thanks for your help. 

The first problem with me in my code in myGame.cs :

ballMesh = ContentManager.Load<Mesh>("Ball.ase");
            ballMesh2 = ContentManager.Load<Mesh>("Ball.ase");
            ballMesh.MouseEnter += new MouseEventHandler(ballMesh_MouseEnter);


ballMesh = ContentManager.Load<Mesh>("Ball.ase");

ballMesh.MouseEnter += new MouseEventHandler(ballMesh_MouseEnter);

My response function  ballMesh_MouseEnter in myGame.cs:

void ballMesh_MouseEnter(object sender, MouseEventArgs e)




Which cs file should I put the ballMesh_MouseEnter() in ? myGame.cs or MainPage.xaml.cs? Thanks :)



Mar 15, 2010 at 12:38 PM

Since you're loading it in the myGame.cs and hooking it up there, you need to put it in that class.