Creating a simple simulation with gravity
In this recipe, we are going to configure a simple physics scene consisting of a single rigid body (a sphere) and the effects of gravity on it.
Getting ready
Load up PlayStation Mobile Studio and create a new project. Add references to Sce.PlayStation.HighLevel.GameEngine2D
and Sce.PlayStation.HighLevel.Physics2D
. We also need to add a circular sprite; I used a picture of the earth aptly named earth.png
. The complete source and all images used can be found in Ch5_Example1
.
How to do it...
- Add the earth sprite to your project, and set its Build Action to Content.
- Open up the
AppMain.cs
file and replace the existing code with the following code:using System; usingSce.PlayStation.Core; usingSce.PlayStation.Core.Graphics; ...
Get PlayStation®Mobile Development Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.