Chapt 3 role of actors

Post on 13-Jan-2015

114 views 0 download

Tags:

description

 

transcript

1

Chapter 3Role of Actors

mrbash.com| stencyl development

2

Lesson Objectives

•Define the roles of actors in a game.Roles•State the elements of an actor.Elements•List the various input behavior controls used to control actors.Input Controls•Explain the different collision groups that actors are able to respond to.Collision groups

3

Actors Actors are the “living” interactive part of a game.

Actors can be defined as any of the following,

Players Enemies Projectiles Vehicles Interface Elements

4

Role of Actors1. Actors are the essential components of a game.

2. Actors increases the interactivity of a game.

3. Actors are the main focus of a game plot.

4. Actors gives uniqueness to gameplay.

5

Elements of an ActorActors compromise of these 3 elements,

1. Appearance – How the actors look in a game.

2. Behaviour – How the actors behave/act in a game.

3. Physics – How the actors interact with the objects in the game and environment itself.

6

Appearance (Animations)

The first look on an actor illustrates the outward appearance of an actor.

An animation is a group of frames form a visual lifelike motion representation of an actor.

Each actor may contain more than one animation.

7

Appearance (Animation Examples)

Each animation may represent a different state that an actor take in a game.

Here are some examples of an animation state.

8

Appearance (Animations)

An animation consists of 2 portions

1. Frames (How an animation looks like)

2. Collision Bounds (Its collision shape)

9

Appearance (Frames in animation)

Frames are like pages of a sketchbook.

Each frame represents a different page.

When each page is flipped at quickly, these “pages” or frames form an animation.

10

Appearance (Frames in animation)

For instance, an actor in a side scrolling game may contain 2 animations such as “walk left” and “walk right”.

For instance, in the “walk left” animation, it may contain 4 frames.

Each frame may represent both the left foot and right foot being stuck out the player actor walks to the left.

11

Appearance (Frame Duration)

Each frame can be allocated a different duration.

Duration is measured in milliseconds (ms).

Minimum duration is 10ms.

12

Appearance (Looping & Origin Point)

Each animation can be set to loop or play once.

An animation may have an assigned an origin point.

The origin point determines the rotation and scaling of an actor.

13

Appearance(Collision Bounds)

An actor in a different animation/state may take on different states.

In this example, the player is standing has a wider surface area and takes on the shape of a rectangle.

The same player that is in a ducking position has a smaller surface area and takes on the shape of a circle.

14

Actor BehavioursActor behaviours are defined by the way an actor acts in a game.

A behaviour defines the logic that is required for a specific action such as running, walking, jumping, shoot bullets and many more.

A behaviour can be attached to any actor.

15

Input Controls behaviourAfter defining the appearance the actors, we need ways to control them on a computer or mobile platform. Here are some of the ways,

Keyboard (Controls)

Mouse

Mouse over Actor

Cursor

16

Input Controls behaviour

Computer

Keyboard (Controls)

Mouse

Mouse over Actor

Cursor

Mobile

Accelerometer

Virtual-Joystick

Multi-Touch

17

Computer Controls(Keyboard)

Actor responds to a keyboard key press.

When a key press is made, an assigned action will be carried out.

For example, when the “arrow up” button is pressed, the actor may be assigned to jump.

18

Computer Controls(Mouse)

Actor responds to a mouse click.

When the mouse is clicked, an assigned action will be carried out.

For example, when the “left click” button is clicked, the actor may be assigned to shoot in instances like FPS (First Person Shooter) games.

19

Computer Controls(Mouse States)

A mouse event in sensed in 3 states.

1. Pressed (happen once)

2. Released (happen once)

3. Down (constant state when held down)

Take for example the firing of a gun.

4. Pressed (Manual firing)

5. Down (Automatic firing)

20

Computer Controls(Mouse over Actor)

A mouse over event in sensed in 4 states.

1. Pressed on Actor.

2. Released on Actor.

3. Down on Actor.

4. Over Actor.

21

Computer Controls(The cursor)

A cursor event in used to show or hide the cursor in different instances.

Not always used.

22

Mobile Controls

In Stencyl 3, a mouse input event is treated the same as a touch event on the mobile screen.

No separate blocks are required for both of these events.

23

Mobile Controls(Accelerometer)

Some games require a user control to tilt the device the device.

Example of games on the iOS that require tilt action are “Into the dead” and “Tilt Racing”.

24

Mobile Controls(Accelerometer values)

Accelerometer design blocks can be found under the User Input > Mobile category in the instruction palette.

Values are measured in 3 directions.

1. X of accelerometer

2. Y of accelerometer

3. Z of accelerometer

25

Mobile Controls(Accelerometer values)

Accelerometer values range from -1.0 to 1.0

An example of ,Y = 1 would mean user is tilting extremely to the top.

26

Mobile Controls(Accelerometer values)PORTRAIT ORIENTATION

X (Positive) = Right

X (Negative) = Left

Y (Positive) = Up

Y (Negative) = Down

LANDSCAPE ORIENTATION

X (Positive) = Up

X (Negative) = Down

Y (Positive) = Left

Y (Negative) = Right

27

Mobile Controls(Joystick)

Some games require a user to precisely control an actor freely.

Movement ranges from 0 to 360 degrees.

Used as input to move characters in game by holding on to desired direction.

28

Mobile Controls(Enabling Joystick)

3 block of codes associated with enabling joystick,

1.Enable joystick

2.Joystick direction (0 to 360 degrees)

3.Joystick distance (how far user has held on to direction controls from origin)

29

Mobile Controls(Joystick Configuration)

Click on game "Settings“

Under mobile, click on joystick.

Joystick appearance and joystick can be customised here.

30

Mobile Controls(Multi-touch)

Not all games require single touch.

Some games require multi-touch as game inputs.

Multi-touch events are used to handle multi-touch instances.

31

PhysicsThe physics in games is very much similar to that of the real world.

An example of that would be gravity. In a game, we can tweak physics to the parameters that we want.

We can choose to have gravity for a Mario like game or negate the gravity to have a space ship float in a space invaders game.

32

Physics(General tab)

Cannot Move: The actor cannot move or be moved, thus, becoming stationary.

Cannot Be Pushed: The actor can move but cannot be moved by another actor.

Normal: The Actor can move on its own and be moved by other Actors.

33

Physics(General tab)

Can Rotate?

Determines whether or not your actor can rotate.

Rotation happens either naturally through physics, setting the turning speed or twisting it with some force.

34

Physics(General tab)

Affected by Gravity?

Gravity is a constant force that affects all bodies within a scene.

Gravity can be set to any direction and magnitude (strength) via the Physics page of a Scene. Gravity does not always point down.

You can set an Actor to obey or ignore gravity.

35

Actor Collision GroupsGroups are basically collection of actors

Default groups exist such as players, enemies and tiles.

Groups can be created for almost any categories of actors

Players Enemies Tiles

36

Actor Collision GroupsOften a times, actors collide within each other in a game environment.

For instance, when a car crashes into a tree, the point when the car hits makes contact with the tree is known as a collision.

The collision takes place between both the bullet and enemy actors.

37

Actor Collision Groups(Setting up groups)

Click on game "Settings“

Click on groups.

38

Questions?