Operating Systems. Windows Mobile. Game Artificial Intelligence. Game Design. Game Optimization. Game Scripting. Game Strategy. Mobile Game Development. Virtual Reality. Game Engines. Embedded Systems. Home Automation. Industrial Internet of Things. IoT Development. IoT Security. Single Board Computers. Wearable Tech. Application Security. Cloud Security. Information Security. Malware Analysis. Reverse Engineering. Web Penetration Testing. Audio Processing. Document Preparation. Image Editing. Project Management. Soft Skills. User Experience. Workflow Automation. Business Management.
Enterprise Resource Planning. Operations Management. Real Time Communication. UI Development. Video Editing. PlayStation Mobile Development Cookbook. Over 65 recipes that will help you create and develop amazing mobile applications! Skip to the end of the images gallery. Skip to the beginning of the images gallery. Read Now Look inside. More Information Learn Discover how to handle multiple sources of input to really help you create something unique Load and animate sprites within your own 2D game to get up and running quickly with the SDK Harness the power of the GameEngine 2D library to make your workflow easier Add engaging physics to your game projects with amazing ease Learn how to play a variety of sound effects and music and increase player immersion Create and navigate a 3D world, taking your visuals to the next level Use 3D models and shaders to make your projects look stunning Add multiplayer functionality for exciting competitive and cooperative gameplay About With the PlayStation Mobile SDK you can create stunning games for the PlayStation Vita and PlayStation Certified devices PS Certified devices.
Table of contents. Introduction Handling the controller's d-pad and buttons Using the Input2 wrapper class Using the analog joysticks Handling touch events Using the motion sensors Creating onscreen controls for devices without gamepads Configuring an Android application to use onscreen controls. Introduction Handling updates with Scheduler Working with the ActionManager object Using predefined actions Transitioning between scenes Simple collision detection Playing background music Playing sound effects.
Introduction Creating a simple simulation with gravity Switching between dynamic and kinematic Creating a physics! Introduction "Hello World" — HighLevel. Introduction Creating a simple 3D scene Displaying a textured 3D object Implementing a simple camera system A fragment pixel shader in action A vertex shader in action Adding lighting to your scene Using an offscreen frame buffer to take a screenshot. Introduction Importing a 3D model for use in PlayStation Mobile Loading and displaying a 3D model Using BasicProgram to perform texture and shader effects Controlling lighting using BasicProgram Animating a model Handling multiple animations Using bones to add a sword to our animated model.
Introduction Opening and loading a web browser Socket-based client and server networking Accessing Twitter data over the network using REST and HttpWebRequest Copying and pasting using Clipboard Embedding and retrieving a resource from the application assembly Configuring your application using PublishingUtility Creating downloadable content DLC for your application.
Authors Michael Fleischauer Michael Fleischauer has spent the last 16 years working as a programmer in a number of different industries from 3D tools creation to automotive and banking. Add to Cart. What do I get with a Packt subscription? Exclusive monthly discount - no contract Unlimited access to entire Packt library of over eBooks and Videos new titles added every month on new and emerging tech. What do I get with a Video? Download this Video course in MP4 format DRM FREE - read and interact with your content when you want, where you want, and how you want Immediately access your video course for viewing or download through your Packt account.
What do I get with an eBook? Add To Cart. Start a FREE day trial. New Products. Discover how to handle multiple sources of input to really help you create something unique Load and animate sprites within your own 2D game to get up and running quickly with the SDK Harness the power of the GameEngine 2D library to make your workflow easier Add engaging physics to your game projects with amazing ease Learn how to play a variety of sound effects and music and increase player immersion Create and navigate a 3D world, taking your visuals to the next level Use 3D models and shaders to make your projects look stunning Add multiplayer functionality for exciting competitive and cooperative gameplay.
Accessing the PlayStation Mobile portal. Creating a simple game loop. Loading, displaying, and translating a textured image. In the following example we attach four sprites to an instance of CCParallaxNode. We then set parallaxRatio and parallaxOffset to create the desired effect. A ratio of ccp 2,0 means the sprite will scroll twice as fast on the X and not at all on the Y. Higher faster ratios are typically drawn closer to the camera. Once the main CCParallaxNode instance moves the children will move with the proper ratio.
There are a number of ways to loop a parallaxed background. Lighting using glColorMask Lighting is a fundamental part of most 3D video games. This adds suspense to our 2D scene. In this recipe we see a monk walking through a dark cave carrying a lantern. The monk's lantern gives off light in a circular shape that illuminates dark parts of the scene.
As the monk moves through the cave a colony of bats becomes visible. Also note that code used to create the 'flying bats' effect has been omitted as that was covered in a previous recipe. This represents the cone of light created by the monk's candle. This simulates darkness in the cave. This transforms to the proper location, among other things. Cocos2d exposes just the right amount of OpenGL drawing logic to make complex manipulations of rendering order look easy. To achieve this effect we use CCRenderTexture.
First, we clear the screen using the following call: [darknessLayer clear This, in effect, tells OpenGL to modify the opacity only the opacity, not the color of the graphics buffer based on what we render. So, we render the fire. Finally, we additively draw another fire. The node darknessLayer is only rendered within the screen's viewing area while burnSprite and lightSprite are rendered at the lantern's position. Using a similar technique lights can be created in all shapes, sizes, and colors.
These can include animated lights like torches, shaped lights like a car's headlights, or short, quick lighting effects like a bright flash from an explosion. Most importantly, this effect gives us the ability to tease the player with what may or may not lurk in the shadows of the game world. In this chapter, we will cover the most common input methods using both the touch screen and the accelerometer. User Input Tap, hold, and drag input Tapping, holding, and dragging are the most commonly used input techniques.
They form the basic building blocks of input for user interfaces as well as for interacting with game objects. In this recipe, we subclass CCSprite in order to create a sprite which can process touch events and maintain some custom state information. This, plus some logic, allows us to touch, hold, and drag this sprite. Here is where we maintain state variables to let us differentiate between a tap, a hold, and a drag.
We also specify a CGRect rect method. This is used to determine whether or not the sprite was touched. Whenever we touch the layer we call ccTouchesBegan. When we move we call ccTouchesMoved. Finally, when we lift a finger up we call ccTouchesEnded. Each method does a pointIsInRect check and then calls the requisite touches method on the sprite. Finally, the sprite runs some simple logic to determine state and to allow dragging of the sprite. The technique used previously is not the only way to capture input.
Cocos2d also provides the CCTouchDispatcher class. With this you can implement methods in the CCTargetedTouchDelegate protocol and assign a delegate object to automatically handle your touch input. See also For more information on this method please consult the official Cocos2d documentation and the Cocos2d forum. Using an array of sprites sorted by Z order we can "swallow the input" so that background sprites aren't affected. Execute the following code: import "ColorTouchSprite. Our array of sprites has a node order which corresponds directly to their Z order. So, looping through these sprites does implicit depth testing.
When a sprite touch begins we swallow the input allowing only that sprite to be touched. Any modification of sprite Z order requires a re-sorting of nodes in the array.
- Sony will launch a 'PS5 Pro' alongside the PlayStation 5: report!
- PlayStation(R)Mobile Development Cookbook - Michael Fleischauer - Google книги.
- Playstation R Mobile Development Cookbook Fleischauer Michael.
- remarkable, Playstation mobile development cookbook stand share?
- Return Policy.
- Posts navigation.
Creating buttons Buttons in one form or another are used in most games. It is easy to implement a simple button solution using Cocos2d but creating one that supports multiple simultaneous button touches is more difficult. In this recipe, we will implement a simple but effective solution to this problem. This recipe uses a couple of different classes, all derived from CCSprite, to create realistic buttons.
These buttons can all be touched independently. This way we can keep track of each unique touch.
A touch can even be used to touch two buttons at once. This, along with using pointInCircle for touch detection, allows us to press two buttons with one well placed touch. This is vital for many games. For example, the original Super Mario Brothers required the user to hold down the B button to run while pressing the A button to jump. This technique allows a similar use of the Y and A buttons. Creating a directional pad Another fundamental form of video game input is the directional pad.
In this recipe, you will see how to create a convincing 3D-ish directional pad and you will see how to properly process directional pad information in a game situation.
Execute the following code: import "TouchableSprite. This recipe uses a few simple tricks to make a compelling directional pad effect. First, we must look at the DPad class. It then divides the image into eight directional slices. Each direction corresponds to a different sprite frame. When everything is put together we get a nice looking pseudo-3D effect.
This allows us to determine which of the eight directions our "gunman" sprite should be facing and how we should set his velocity variable to instigate movement. This makes the control feel a little more natural to the user. We do this because, on a real directional pad, pressing directly in the middle results in no movement. This input method measures vector magnitude as well as direction. We've also created a cool looking visual effect for the analog stick. Using the AnalogStick class provides the user with more precise control. Without going into too much detail, this creates a nice analog stick visual effect.
Like our DPad class from the previous recipe, our AnalogStick class also includes a dead zone. This points to a method that does the proper calculations. The reason we provide this zone is so the user can comfortably make the 'gunman' run at top-speed. Using the accelerometer for steering iOS applications also have another form of input: the accelerometer. Device orientation is a dynamic if slightly delayed input mechanism with a variety of uses. One of these uses is steering in racing video games. Rotating your iPhone left or right while looking directly at the screen will result in seeing the steering wheel rotate.
The 3D vector contained within the UIAcceleration variable goes up or down by 1 for every 90 degrees the iOS device rotates. So, by multiplying this rotation by degrees, we equate a degree tilt with a degree turn of the steering wheel. This makes its application impractical for some gametypes where absolute split second control is required. Using the accelerometer for 3D rotation Using multiple accelerometer values at once can allow the user to manipulate the rotation of a 3D object in space.
Please note that the IphoneCube class code was omitted from this example as it is similar to the 3D cube code in Chapter 1, Graphics.
Execute the following code: import "IphoneCube. Rotating your device on the X or Y planes will result in rotating the virtual iPhone onscreen. We multiply the acceleration variable by to once again rotate our object twice as much as the device itself. In this recipe, we will see how to zoom a scene in and out by pinching.
Also note that the arrow effect shown in the previous screenshot has been omitted from the following code. This recipe processes two separate touches and determines their respective distance. It maintains this variable to determine whether or not the touches have grown closer or farther apart. Then, this distance is used to calculate the new zoom level. The touches variable contains every touch at that specific moment.
If two touches move together this one method can easily process them. If you want to add to this technique, try implementing iPhoto-esque image panning. Performing gestures Gestures can act as functional input shortcuts. Simple gestures like swiping and scrolling are built into many Apple UI tools. In this recipe, we will implement a simple and admittedly crude gesture system. GestureLine simply contains two CGPoint structures. GestureShapeLayer draws a circle or an array of lines.
Execute the following code: import "GestureLine. This gesture system tracks each individual point of user input. Each pair of points creates a 2D vector. When the current vector's angle is different enough from the previous one, then we consider that this is a new vertex of a shape the user is drawing. We then take this vertex and the last one, and create a line. By storing every point and line we can determine what the user is attempting to draw.
This system, as implemented, leaves much to be desired. However, it provides the conceptual groundwork for a more complex and functional system. By looking at the succession of points in a certain light we can see patterns emerge. In this example, we looked for successive vectors with vastly different angles to determine drawn lines.
Other things like curves, direction, and point distance can lead to the identification of more complex shapes. This includes hi-scores, player profiles, and saved game sessions to name a few. In this chapter, we will use a number of varied techniques to read and write data.
Loading data from a PLIST file is a seamless way to create a complex structure of data in the memory of your program. Here we load scene1. Inside each dictionary we have a string value with a key of 'type'. This tells the application what kind of node it is looking at. The PLIST data format can house an infinitely deep combination of arrays and dictionaries that ultimately contain primitive data types including Boolean, Data, Date, Number, and String. The previous figure is a graphical representation of the XML data.
As you'll see in later examples, combinations of arrays and dictionaries are the standard for storing data. This allows classes that require exact paths to manipulate files in the filesystem. This technique is simulated isometric projection. This is simulated 3D space with no vanishing point.
It is used in countless 2D games and will be a primary feature of many more recipes in this book. It is a very light and easily consumable way of packing your data. In the following scene, we see a grassy field with a cat and a few trees: Getting ready Please refer to the project RecipeCollection01 for full working code of this recipe. Execute the following code: import "ActualPath. At a glance, it is much easier to understand than XML. In the following scene, we see rocky terrain with some boulders and weeds: Chapter 3 Getting ready Please refer to the project RecipeCollection01 for full working code of this recipe.
In your Project Navigator click on your Project. To the right of this, click on your Target. Go to the Build Settings tab. Add -lxml2 to the list. Attributes can be used to provide additional information about an Element. Namespaces can be used to help reduce the ambiguity between Elements. In this example, we are saving the default difficulty level for our game. It can also accept arrays and dictionaries. We took a brief look at menu customization in this recipe. We will talk about this topic at length in Chapter 4, Physics.
By conforming to the NSCoding protocol, we can tell the archiver how to pack and unpack any of our classes. In this recipe, we will be packing up a character who has a number of Dungeons and Dragons style attributes. Also note that some of the following code has been omitted for brevity. Properly archiving an object requires a few steps. These include the Documents and the Library directories.
In this and future examples, we may read from a number of locations within the app bundle but we will usually only write to the Documents directory. Unlike other areas on the disk, files saved here will be maintained when an app is upgraded. Typically, we save pre-made templates in a read-only section, copy them into the Documents directory, load them into memory, and then save modified versions in the Documents directory. This non-mutable structure leaves the data un-editable. In this recipe, we will read in a nested JSON data structure and then recursively re-create the data using mutable data structures to allow the data to be edited.
Execute the following code: import "GameHelper. The data consists of a NSDictionary object with nested arrays, dictionaries, and, finally, strings. Click the Randomize Data button to randomly change some data in the structure. In this recipe, we see a whack-a-mole game that will use a PLIST file to maintain a list of hi-scores.
Ubisoft - Careers / Grads & Interns
For the sake of brevity all game logic has been omitted from the following code. The first thing we do is check the Documents directory for whackamole. Saving data into an SQLite database The second game we have is a "skeet shooting" game where discs are fired in the air and the goal is to shoot as many down as possible within a certain time limit. For this game, we will persist hi-score data using a SQLite database. For the sake of brevity, all game logic has been omitted from the following code.
To use SQLite we first need to do a few things: 1. First we need to add the libsqlite3. In this recipe, we have one table with two values. Feel free to experiment with more complex data models. Flip over two matching cards and you get a point. Flip over two that don't match and you get a strike. Three strikes and you're out. For this game we persist hi-score data using Apple's Core Data model pattern. Setting up our Core Data based recipe requires a number of steps.
First we need to add the CoreData framework. Create a new folder inside your resources entitled Data Model. Name this data model hiscore and add your existing Hiscore class to this data model when you are prompted. Click on hiscores. Click on the Hiscore entity and then add two new properties to it which correspond to the two properties in your Hiscore class: Now we're ready to get down to some code. Execute the following: import import "Hiscore. If the context doesn't already exist, it is created and bound to the persistent store coordinator for the application.
If the model doesn't already exist, it is created by merging all of the models found in the application bundle. If the coordinator doesn't already exist, it is created and the application's store added to it. This example serves merely as a working introduction to using Core Data. Getting Core Data to work properly in XCode can sometimes be somewhat tricky. To fix this problem make sure your xcdatamodel files and your NSManagedObject classes are located in the same folder on the disk as well as in the same XCode group.
If this doesn't fix the problem delete these files from the project but not the disk then re-add them. If that doesn't work you can also create a SQLite database manually. This requires you to follow Core Data conventions. This file has the correct Core Data database structure.
The recipe will also use this file if it fails to create the SQLite database. However, applications with complex underlying data structures can benefit from the level of abstraction and robust toolset Core Data provides. In many games, physics plays a crucial role within the gameplay. Cocos2d comes bundled with two popular 2D physics engines: Box2D and Chipmunk. In this chapter, we will explain the most common uses of physics in games using Box2D as our engine of choice. Most of the recipes here can be easily modified to use Chipmunk or any other similar physics engine.
Physics Box2D setup and debug drawing In our first physics recipe, we will explore the basics of creating a Box2D project and setting up a Box2D world. The example creates a scene that allows the user to create realistic 2D blocks. Getting ready Please refer to the project RecipeCollection02 for full working code of this recipe. The first thing we need to do is create a Box2D project using the built-in Box2D project template: 1. Go to File New Project. Under User Templates click on Cocos2d.
Now, right click on Cocos2d Box2d Application. Click Choose, name your project, and hit Save. Now, execute the following code: import "Box2D. Set 0. SetAsEdge b2Vec2 0,screenSize. SetAsEdge b2Vec2 screenSize. Set p. The Box2D sample project is a simple way to understand what a physics system looks like. Sleeping allows bodies that are at rest to take up less system resources. Debug drawing encompasses drawing five different elements onscreen.
These include shapes, joint connections, AABBs axis-aligned bounding boxes , broad-phase pairs, and a center of mass bit. PTM stands for pixel to meter. Box2D measures bodies in meters and is built and optimized to work with bodies between the sizes of 0. Setting this ratio to 32 is a common convention for optimal shapes to appear between 3.
Optimization aside, there is no upper or lower limit to Box2D body size. This is handled with the creation of a b2Body object with four fixtures. Each fixture has a b2Polygon shape that defines a single edge. Creating an edge typically involves the following: b2BodyDef bodyDef; bodyDef. We then set the density and friction attributes of the fixture. We also set bodyDef. This links the visual and the physical, and allows our step: method to reposition sprites as necessary.
The Box2D constraint solver runs in two phases: the velocity phase and position phase. These determine how fast the bodies move and where they are in the game world. Setting these variables higher results in a more accurate simulation at the cost of speed. Setting velocityIterations to 8 and positionIterations to 3 is the suggested baseline in the Box2D manual. Using the dt variable syncs the logical timing of the application with the physical timing. If a game step takes an inordinate amount of time, the physics system will move forward quickly to compensate.
This is referred to as a variable time step. Creating collision response routines To make efficient and organized use of Box2D, we must create a few wrapper classes to encapsulate specific functionality. In this recipe, we will use these classes to add collision response routines to our simple falling block demo from the previous recipe. It will need to be overridden. This recipe lays the groundwork for the rest of this chapter. Here, we see the same block creation recipe from before except now a message is printed on the screen when either blocks collide with each other or they collide with a sensor.
It also includes a pointer back to its parent GameArea object as well as some other information we will use later. GameObject is intended to be an abstract base class that should be extended for specific uses. This allows collision response routines to run without the body actually existing in the world physically. No physical collision response will occur. We've encapsulated this functionality in the GameSensor class.
An object of this class can be differentiated from other objects by checking its type property. The only added functionality in GameMisc is the life variable that we will use in later recipes. Here, we encapsulate most of the functionality outlined in the previous recipe. These allow us to draw our debug information and our game information separately from the main scene. This feature will come in handy as recipes become more complex. We extend b2ContentListener to create the basicContentListener class.
The former is called when two fixtures begin to touch, the latter when they cease to touch. The PreSolve and PostSolve methods are called before and after the contact solver routine runs. We will use this functionality in a later recipe. For this recipe, we are only concerned with BeginContact. There's More In this example, blocks are colliding with a static sensor.
Static bodies never move and they do not collide with each other. Dynamic bodies move freely and collide with all other bodies. In this recipe, we will create a number of different shapes. In this recipe, we randomly create objects with five different shapes: square, circle, rectangle, an oddly shaped convex polygon, and a simple concave polygon.
In this example, we have a simple textured square as well as a rectangular column image. In this example, we also give the circle shaped objects a high restitution value to make them bounce. We will cover this in more depth in another recipe. This means that every angle inside the polygon is less than degrees. For this example, we've created an oddly shaped convex polygon with 8 vertices. We are using TexturedPolygon to accurately draw this polygon.
PlayStation?Mobile Development Cookbook
For more information about the TexturedPolygon class, please refer to Chapter 1, Graphics. In this example, we link two simple convex polygons together by creating two fixtures on the same body. We reverse our width and height values to create a simple L-shaped object. With this technique, you can create arbitrarily complex shapes.
However, as you can see in the concave polygon example, you can create multiple CCSprite objects and link them to the main GameObject sprite. You can also reuse the Box2D object pointers within the GameObject instance to easily create multiple fixtures and shapes. Dragging and collision filtering In a previous recipe, we handled user input to allow the user to drag an object.
In this example, we see a bowl filled with pieces of fruit that can be dragged across the screen. A piece of fruit does not collide with another piece of fruit. SetAsEdge b2Vec2 In this example, we create a realistic 'grabbing' effect. We apply this velocity using the SetLinearVelocity method: grabbedFruit. We achieve this by setting the filter property on the fruit's fixture. The maskBits variable indicates what kind of objects this should collide with. Both of these properties use bits and Boolean logic to specify how the object should interact.
For example, means "or". Alternatively, filters can be set using filter groups. Also note that, if you do not specify the fixture's filter variable on object then it will not collide with an object that has a set filter. Manipulating physical properties Box2D allows the user to set physical properties on bodies to create a wide array of effects. In this example, we see a block of ice pushing a box down a slope. We also see a number of bouncing balls. In this example, we see multiple objects each with different physical properties.
Two objects with different sizes and the same density will have different masses. The larger object will naturally take a larger force to move. Physics nerds may point out the difference between static and kinetic friction. Box2D amalgamates them into one variable while assuming a constant static to kinetic ratio.
In our example, the block of ice has absolutely no friction.
This means that it will slide around on any surface. This allows the block to slowly push the crate down the ramp until it finally falls on the bouncing balls. This measures the 'bounciness' of an object. An object with a restitution of 1. In our example, we see four balls each with a different restitution. This causes them to bounce at different rates. To see these differences in action, quickly grab the block of ice before it pushes the crate over the edge of the ledge.
In this recipe, we will use impulses to accurately shoot a basketball into a basketball net. Set 0,0 ; gameObjSensor.
In this scene, we see a basketball player shooting the ball into a basket. When he comes in contact with the ball he shoots it into the net. Instead of applying a force over time, an impulse applies instantaneous force to immediately redirect an object. Impulses also wake up a sleeping body if necessary. For more granular object identification, you can use the typeTag enumeration. This allows us to tag objects to perform a number of tasks. In this example, we use typeTag during collision response to properly animate the basketball player as well as the basketball net.
In this recipe, we see a simulation of our solar system. We determine the shape size from the texture size. In this scene, we see eight planets orbiting the sun. They orbit at roughly the same speed. The forces applied take into account planet size and distance from the sun in a way similar to how real gravity works. If this is not the exact center of mass, then a torque will also be applied to the object. This will change the angular velocity of the body and will make it spin. Setting gravity to b2Vec2 0. We will use this technique in later recipes, including Creating a top-down isometric game engine found later in this chapter.
In this example, we will see how to destroy a body during the physics simulation. This is naturally a very tricky process that can create bugs and cause game crashes if you're not careful. Set grenadePosition. In this recipe, we have the ability to throw grenades that explode after five seconds. The explosion launches any other objects in the immediate area. Because of this, collision response routines and timed callbacks cannot synchronously initiate body destruction. To solve this problem, we have created a simple asynchronous system that can queue up bodies for destruction and creation.
This can help maintain a logical order of operations when the game is running. In this recipe, we get to put it to use. Each grenade's life ticks away until it explodes. The explosion created is also a GameMisc object with a set amount of life corresponding to its animation duration. Life can also be used for actors and breakable objects. Joints allow us to link objects to create simple machines like pulleys, levers, and simple motors. In this recipe, we will learn how to create a simple seesaw using a joint. Set trianglePosition. Set plankPosition.
Initialize plank. By dropping the heavy weight object on one side, we can launch the lighter boxes up into the air from the other side. This is achieved using a simple joint. Each joint is represented by a class that derives from b2Joint. A comprehensive overview of all Box2D joint types is beyond the scope of this book. Now that it can't move, it can only rotate.
This creates a realistic seesaw effect. Add to Cart. Free delivery. Arrives by Tuesday, Oct 8. Faster delivery options available at checkout. Free pickup Tue, Oct 8. Ships to San Leandro, Davis St. Gifting note: Ships in the manufacturer's original packaging, which may reveal the contents. Product Highlights About This Item We aim to show you accurate product information. Manufacturers, suppliers and others provide what you see here, and we have not verified it. See our disclaimer. With this problem-solving cookbook, you'll get started in two ways: First , you'll learn about the Unity game engine through brief recipes that teach specific features of the software and scripting systems.
You'll find solutions for: 2D and 3D graphics Math, physics, and character control Animation and movement Behavior and AI Sound and music Input and gameplay Scripting and user interface. Specifications Publisher O'Reilly Media. Customer Reviews. Write a review. See any care plans, options and policies that may be associated with this product.