| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- // ----------------------------------------------------------------
- // From Game Programming in C++ by Sanjay Madhav
- // Copyright (C) 2017 Sanjay Madhav. All rights reserved.
- //
- // Released under the BSD License
- // See LICENSE in root directory for full details.
- // ----------------------------------------------------------------
- #include "BallActor.h"
- #include "Game.h"
- #include "Renderer.h"
- #include "MeshComponent.h"
- #include "Mesh.h"
- #include "BallMove.h"
- #include "AudioComponent.h"
- BallActor::BallActor(Game* game)
- :Actor(game)
- ,mLifeSpan(2.0f)
- {
- //SetScale(10.0f);
- MeshComponent* mc = new MeshComponent(this);
- Mesh* mesh = GetGame()->GetRenderer()->GetMesh("Assets/Sphere.gpmesh");
- mc->SetMesh(mesh);
- mMyMove = new BallMove(this);
- mMyMove->SetForwardSpeed(1500.0f);
- mAudioComp = new AudioComponent(this);
- }
- void BallActor::UpdateActor(float deltaTime)
- {
- Actor::UpdateActor(deltaTime);
-
- mLifeSpan -= deltaTime;
- if (mLifeSpan < 0.0f)
- {
- SetState(EDead);
- }
- }
- void BallActor::SetPlayer(Actor* player)
- {
- mMyMove->SetPlayer(player);
- }
- void BallActor::HitTarget()
- {
- mAudioComp->PlayEvent("event:/Ding");
- }
|