-
-
Save asfdfdfd/e822c197f14f32dbd4b2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "TicTacToe.h" | |
#include "GameFieldActor.h" | |
AGameFieldActor::AGameFieldActor(const class FPostConstructInitializeProperties& PCIP) | |
: Super(PCIP) | |
{ | |
TSubobjectPtr<UArrowComponent> componentArrow = PCIP.CreateDefaultSubobject<UArrowComponent>(this, TEXT("GameFieldActorRootComponent")); | |
RootComponent = componentArrow; | |
static ConstructorHelpers::FObjectFinder<UBlueprint> gameFieldCellTemplateBlueprintFinder(TEXT("/Game/Blueprints/BP_GameFieldCellSprite")); | |
auto gameFieldCellGeneratedClass = gameFieldCellTemplateBlueprintFinder.Object->GeneratedClass; | |
TSubclassOf<class AActor> gameFieldCellActorClass = *gameFieldCellGeneratedClass; | |
int locationRow = -20; | |
for (int i = 0; i < 3; i++) { | |
int locationCol = 20; | |
for (int j = 0; j < 3; j++) { | |
const FString componentName = FString::Printf(TEXT("GameFieldCell_%dx%d"), i, j); | |
TSubobjectPtr<UChildActorComponent> componentCell = PCIP.CreateDefaultSubobject<UChildActorComponent>(this, *componentName); | |
componentCell->ChildActorClass = gameFieldCellActorClass; | |
componentCell->SetRelativeLocation(FVector(0, locationRow, locationCol)); | |
componentCell->AttachTo(componentArrow); | |
locationCol -= 20; | |
} | |
locationRow += 20; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment