프로그래밍/Unreal
[13]Battery Collector_HUD 블루프린트 만들기
redjam0123
2017. 5. 12. 20:10
17.Creating the HUD Blueprint
BatteryCollectorGameMode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 |
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/GameMode.h"
#include "BatteryCollectorGameMode.generated.h"
UCLASS(minimalapi)
class ABatteryCollectorGameMode : public AGameMode
{
GENERATED_BODY()
public:
ABatteryCollectorGameMode();
virtual void Tick(float DeltaTime) override;
//Returns power needed to win - needed for the HUD
UFUNCTION(BlueprintPure, Category = "Power")
float GetPowerToWin() const;
virtual void BeginPlay() override;
protected:
/**The rate at which the character loses power */
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
float DecayRate;
/**The power needed to win the game*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
float PowerToWin;
/**The widget class to use for our HUD screen*/
UPROPERTY(EditDefaultsOnly, BlueprintReadWrite, Category = "Power", Meta = (BlueprintProtected = "true"))
TSubclassOf<class UUserWidget> HUDWidgetClass;
//The instance of the HUD
/***/
UPROPERTY()
class UUserWidget* CurrentWidget;
}; |
cs |
BatteryCollectorGameMode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13 |
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "BatteryCollector.h"
#include "BatteryCollectorGameMode.h"
#include "BatteryCollectorCharacter.h"
#include "Kismet/GameplayStatics.h"
#include "Blueprint/UserWidget.h"
float ABatteryCollectorGameMode::GetPowerToWin() const{
return PowerToWin;
}
|
cs |
Get Player Character는 유일하게 파워에 대한 정보를 갖고있는 노드
BatteryCollector 캐릭터로 형변환해주어야한다