Presentation is loading. Please wait.

Presentation is loading. Please wait.

Resources and interactions

Similar presentations


Presentation on theme: "Resources and interactions"— Presentation transcript:

1 Resources and interactions
A game’s structure Resources and interactions

2 Games as interactive software
A game is much like a movie Actors Cameras Location Script Sounds and music Director

3 Scenes and GameObjects
Scenes are a collection of images, sounds, game logic, etc.. A Sprite Game Object is used for the display of both static and animated images in your game. Sprites can have input events and physics bodies. They can also be tweened, tinted, scrolled and animated. An Image is a light-weight Game Object useful for the display of static images in your game, such as logos, backgrounds, scenery or other non-animated elements. Images can have input events and physics bodies, or be tweened, tinted or scrolled. The main difference between a Sprite and an Image Game Object is that you cannot animate Images. As such, Sprites take a fraction longer to process and have a larger API footprint due to the Animation Component. If you do not require animation then you can safely use Images to replace Sprites in all cases.

4 Cameras and Rendering The Camera is the way in which all games are rendered in Phaser. They provide a view into your game world, and can be positioned, rotated, zoomed and scrolled accordingly. A Camera consists of two elements: The viewport and the scroll values. The viewport is the physical position and size of the Camera within your game. Cameras, by default, are created the same size as your game, but their position and size can be set to anything. To adjust the viewport you can use methods like setViewport and setSize. If you wish to change where the Camera is looking in your game, then you scroll it. You can do this via the properties scrollX and scrollY or the method setScroll. Scrolling has no impact on the viewport, and changing the viewport has no impact on the scrolling. By default a Camera will render all Game Objects it can see. You can change this using the ignore method, allowing you to filter Game Objects out on a per-Camera basis. A Camera also has built-in special effects including Fade, Flash and Camera Shake.

5 AI and Navigation In video games, artificial intelligence (AI) is used to generate responsive, adaptive or intelligent behaviors primarily in non-player characters (NPCs) similar to human-like intelligence. In our course, we will explore Decision Trees and Steering Behaviors. Pathfinding or pathing is the plotting, by a computer application, of the shortest route between two points. It is a more practical variant on solving mazes. In this course, we will explore Search Algorithms and Pathfinding Algorithms like: BFS DFS Dijakstra A*

6 Sound and Music Although self-explanatory, Audio plays an extremely important part in a video game The sound manager is responsible for playing back audio via Web Audio API or HTML Audio tag as fallback. The audio file type and the encoding of those files are extremely important. Not all browsers can play all audio formats.

7 Supported browsers and audio

8 A game is more than a movie
The player is not passively witnessing what happens, he/she makes it happen! Interactivity shifts responsibility on the player. Player-to-character identification pushes the boundaries of the medium. Unlike a movie, progression is a reward!

9 Input handling The Input Manager is responsible for handling the pointer related systems in a single Phaser Game instance. Based on the Game Config it will create handlers for mouse and touch support. Keyboard and Gamepad are plugins, handled directly by the InputPlugin class. It then manages the event queue, pointer creation and general hit test related operations. You rarely need to interact with the Input Manager directly, and as such, all of its properties and methods should be considered private. Instead, you should use the Input Plugin, which is a Scene level system, responsible for dealing with all input events for a Scene. The input manager

10 Input handling The Input Plugin belongs to a Scene and handles all input related events and operations for it. You can access it from within a Scene using this.input. It emits events directly. For example, you can do: To listen for a pointer down event anywhere on the game canvas. Game Objects can be enabled for input by calling their setInteractive method. After which they will directly emit input events: The input plugin

11 Colliders and Collisions
Phaser includes 3 Systems to handle Physics and Collisions: Arcade Impact Matter We will be focussing only on the Arcade Physics system for now. An Arcade Physics Collider will automatically check for collision, or overlaps, between two objects every step. If a collision, or overlap, occurs it will invoke the given callbacks.

12 Colliders and Collisions
new Collider(world, overlapOnly, object1, object2, collideCallback, processCallback, callbackContext)


Download ppt "Resources and interactions"

Similar presentations


Ads by Google