C# 클래스 Platformer.Player

This is a game component that implements IUpdateable.
상속: Microsoft.Xna.Framework.DrawableGameComponent
파일 보기 프로젝트 열기: zmthy/play-dead 1 사용 예제들

공개 메소드들

메소드 설명
ApplyPhysics ( GameTime gameTime ) : void

Updates the player's velocity and position based on input, gravity, etc.

Draw ( GameTime gameTime, SpriteBatch spriteBatch ) : void

Draws the animated player.

EnterLevel ( Platformer.Level level ) : void
GotoLevel ( int levelIndex ) : void
LoadContent ( Microsoft.Xna.Framework.Content.ContentManager content ) : void

Loads the player sprite sheet and sounds.

OnKilled ( ) : void

Called when the player has been killed.

OnKilled ( String killedBy ) : void
OnKilled ( String killedBy, DeathType killedType ) : void
OnReachedExit ( ) : void

Called when this player reaches the level's exit.

Player ( Microsoft.Xna.Framework.Content.ContentManager content, Vector2 position, DynamicMap dynamicMap ) : System

Constructors a new player.

Reset ( Vector2 position ) : void

Resets the player to life.

Update ( GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState, TouchCollection touchState, AccelerometerState accelState, DisplayOrientation orientation, InputManager inputManager ) : void

Handles input, performs physics, and animates the player sprite.

We pass in all of the input states so that our game is only polling the hardware once per frame. We also pass the game's orientation because when using the accelerometer, we need to reverse our motion when the orientation is in the LandscapeRight orientation.

getPosition ( ) : Vector2

비공개 메소드들

메소드 설명
DoJump ( float velocityY, GameTime gameTime ) : float

Calculates the Y velocity accounting for jumping and animates accordingly.

During the accent of a jump, the Y velocity is completely overridden by a power curve. During the decent, gravity takes over. The jump velocity is controlled by the jumpTime field which measures time into the accent of the current jump.

GetInput ( KeyboardState keyboardState, GamePadState gamePadState, TouchCollection touchState, AccelerometerState accelState, DisplayOrientation orientation, InputManager inputManager ) : void

Gets player horizontal movement and jump commands from input.

HandleCollisions ( ) : void

Detects and resolves all collisions between the player and his neighboring tiles. When a collision is detected, the player is pushed away along one axis to prevent overlapping. There is some special logic for the Y axis to handle platforms which behave differently depending on direction of movement.

IsAlignedToLadder ( ) : bool

Makes sure that the player is aligned to the center of a ladder piece We may not want this, allow for horizontal ladder movement?

checkFallDamage ( ) : void

Checks how far (if at all) the player has fallen. If the player has fallen to far, the player is killed, otherwise the player survives

idle ( ) : void

메소드 상세

ApplyPhysics() 공개 메소드

Updates the player's velocity and position based on input, gravity, etc.
public ApplyPhysics ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
리턴 void

Draw() 공개 메소드

Draws the animated player.
public Draw ( GameTime gameTime, SpriteBatch spriteBatch ) : void
gameTime Microsoft.Xna.Framework.GameTime
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch
리턴 void

EnterLevel() 공개 메소드

public EnterLevel ( Platformer.Level level ) : void
level Platformer.Level
리턴 void

GotoLevel() 공개 메소드

public GotoLevel ( int levelIndex ) : void
levelIndex int
리턴 void

LoadContent() 공개 메소드

Loads the player sprite sheet and sounds.
public LoadContent ( Microsoft.Xna.Framework.Content.ContentManager content ) : void
content Microsoft.Xna.Framework.Content.ContentManager
리턴 void

OnKilled() 공개 메소드

Called when the player has been killed.
public OnKilled ( ) : void
리턴 void

OnKilled() 공개 메소드

public OnKilled ( String killedBy ) : void
killedBy String
리턴 void

OnKilled() 공개 메소드

public OnKilled ( String killedBy, DeathType killedType ) : void
killedBy String
killedType DeathType
리턴 void

OnReachedExit() 공개 메소드

Called when this player reaches the level's exit.
public OnReachedExit ( ) : void
리턴 void

Player() 공개 메소드

Constructors a new player.
public Player ( Microsoft.Xna.Framework.Content.ContentManager content, Vector2 position, DynamicMap dynamicMap ) : System
content Microsoft.Xna.Framework.Content.ContentManager
position Vector2
dynamicMap DynamicMap
리턴 System

Reset() 공개 메소드

Resets the player to life.
public Reset ( Vector2 position ) : void
position Vector2 The position to come to life at.
리턴 void

Update() 공개 메소드

Handles input, performs physics, and animates the player sprite.
We pass in all of the input states so that our game is only polling the hardware once per frame. We also pass the game's orientation because when using the accelerometer, we need to reverse our motion when the orientation is in the LandscapeRight orientation.
public Update ( GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState, TouchCollection touchState, AccelerometerState accelState, DisplayOrientation orientation, InputManager inputManager ) : void
gameTime Microsoft.Xna.Framework.GameTime
keyboardState Microsoft.Xna.Framework.Input.KeyboardState
gamePadState Microsoft.Xna.Framework.Input.GamePadState
touchState TouchCollection
accelState AccelerometerState
orientation DisplayOrientation
inputManager InputManager
리턴 void

getPosition() 공개 메소드

public getPosition ( ) : Vector2
리턴 Vector2