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...

  1. Add the earth sprite to your project, and set its Build Action to Content.
  2. 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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.