Game Development Reference
In-Depth Information
As you can see, no effort is required to consume the WinRT component, and it can
even be easier to use than a C++ class within the same project.
Remember that there are pros and cons to everything, and while there can be major
productivity boosts to developing a component in another language or using exist-
ing code, there is still a small memory and performance penalty, especially if you are
transitioning between managed and unmanaged code, as we are here. This perform-
ance penalty comes from the need to marshal the data types between native code
(C++) and managed code (C#). The shift over to managed code also introduces the
.NET garbage collector, which requires the runtime to start tracking the data.
While the impact is minimal, this could add up if you are doing it many times each
frame. Also remember that because WinRT components need to support JavaScript,
they apply restrictions that may make it difficult to create nicely designed code.
Evaluate the need on a case by case basis and choose the best option for your situ-
ation. In our case we are calling this once when the game ends, presenting a neg-
ligible performance impact. If you want to use managed code in other areas of your
game, it is recommended that you cache references to objects to reduce the impact
of transitioning between native and managed code.
Now if you play the game and lose, not only can you share the score you've
achieved, but you can also exit the game and see the tile update with your latest
score. (Make sure you have pinned your game to the start menu to see this.)
Search WWH ::




Custom Search