2020.01-Study_update.3

Second_week 1.20-1.26

-Study_update
Mon.函数模板①,类模板②,运算符重载复习,派生类复习
Tue.-
Wed.-
Thur.
Friunreal尝试开发①,反射(reflection)与垃圾回收(Garbage collection)②
Sat创建蓝图类,使用C++创建静态网格组件,Delete the C++ class,Create actor and add StaticMesh
Sun.Property

1.20 Monday

函数模板①

template
T max(T a,T b)
{
return a>b?a:b;
}
模板函数当函数模板被调用时,编译器生成相应的模板函数.
res=max(2,5);

#include <iostream>
using namespace std;

template<typename T>
T add(T a, T b)
{
 T res;
 res = a + b;
 return res;
}
int main()
{
 float num1 = 1.2, num2 = 2.4;
 int num3 = 3, num4 = 5;
 float res1 = add(num1, num2);
 int res2 = add(num3, num4);
 cout << res1 << "\n" << res2 << endl;
}//洋葱骑士
类模板②
定义:建立一个通用类,用来处理功能相同,但是数据类型不同的多个类。使用时必须显式的指定类型。例如vector就感觉是一个类模板。

1.24Friday


首先用各种立方体 简单模型构筑游戏理念,制作demo,若觉可行,再进行美化.不推荐使用初始静态物体,因为拉伸会导致模型拉伸,材质贴图变形.使用Geometry能较好的满足需求,但是因为可编辑性强,会比较消耗性能,可以在场景构建满意后转换成static mesh.

Generated应放在最下面.

1.25Saturday

创建蓝图类

Create a news C++ class in the c++classes folder, Select the object Visual studio is also opened.You then need to flll in the code in UCLASS()brackets to create the blueprint class base on this object。Code is Blueprintable

#pragma once
#include "CoreMinimal.h"
#include "UObject/NoExportTypes.h"
#include "MyObject.generated.h"

/**
 * 
 */
UCLASS(Blueprintable)//Fill in This
class MYPROJECT_API UMyObject : public UObject
{
 GENERATED_BODY()
 
};
Delete the C++ class

First,detele the corresponding instance in unreal 4,and then open the C++class folder,find the appropriate file,delete it.go to the nexet folder,delete the Binaries folder.the last step,right cilck tht project file,select tht generate Visual studio project files.REstart project。

Create actor and add StaticMesh

Create C++ class and choose Actor
.h
step 1:Write code UPROPERTY(VisibleAnywhere,Category=“my actor”).
step 2 :Write code UStaticMeshComponent*ComponentName.
.cpp
step 3:write code ==ComponentName=CreateDefaultSubobject(TEXT(“actor”));

and go compile.

public: 
 // Sets default values for this actor's properties
 AMyActor();
 UPROPERTY(VisibleAnywhere,Category="My actor Component")
 UStaticMeshComponent*MyStaticMesh;
AMyActor::AMyActor()
{
  // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
 PrimaryActorTick.bCanEverTick = true;
 MyStaticMesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("actor"));
 }

1.26Sunday

UCLASS()
class MYPROJECT_API AMyActor : public AActor
{ 
GENERATED_BODY()
 
public: 
 // Sets default values for this actor's properties
 AMyActor();
 //添加StaticMeshComponent
  UPROPERTY(VisibleAnywhere,Category="My actor Component")
 UStaticMeshComponent*MyStaticMesh;
 //声明一个FVector类型的初始位置,只能在实例编辑。
 UPROPERTY(EditInstanceonly,Category="My actor Properties | Actor")
 FVector InitLocation;
 //声明一个FVector类型的最初位置,只能在实例编辑。
 UPROPERTY(VisibleInstanceonly, Category = "My actor Properties | Actor")
 FVector PlacedLocation;
 //声明一个布尔类型的变量,决定是否在开始游戏时候初始化位置,只能在蓝图编辑。变量名称前加b.
 UPROPERTY(EditDefaultsOnly, Category = "My actor Properties | Actor")
 bool bGotoInitLocation;
 UPROPERTY(VisibleAnywhere, Category = "My actor Properties | Vector")
 FVector CurrentLocation;
 //声明一个bool类型的变量,决定能否每帧移动一定距离。能在蓝图和实例编辑。
 UPROPERTY(EditAnywhere, Category = "My actor Properties | Actor")
 bool bMoveAble;
 //声明一个FVector类型的变量,决定每一帧移动的距离。
 UPROPERTY(EditAnywhere, Category = "My actor Properties | Actor", meta = (ClampMin = -5.0f, ClampMax = 5.0f,UiMin=-10,UiMax=10))
 FVector TickLocationOffset;
  //关于推力的变量
 UPROPERTY(EditInstanceonly, Category = "My actor Properties | physics")
 FVector InitForce;
 //关于旋转力矩的变量
 UPROPERTY(EditInstanceonly, Category = "My actor Properties | physics")
 FVector InitTorque;
 //决定是否忽视质量直接施加力。
 UPROPERTY(EditAnywhere, Category = "My actor Properties | Actor")
 bool bIgnorePhysics;
 //洋葱骑士
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值