Skip to content

Instantly share code, notes, and snippets.

@asfdfdfd
Created July 27, 2014 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asfdfdfd/e822c197f14f32dbd4b2 to your computer and use it in GitHub Desktop.
Save asfdfdfd/e822c197f14f32dbd4b2 to your computer and use it in GitHub Desktop.
#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