UE4C++ SpringArm组件的创建
UE4C++ SpringArm组件的创建
MyPawn.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"#include "GameFramework/Pawn.h"#include "Components/StaticMeshComponent.h"#include "Camera/CameraComponent.h"#include "Components/InputComponent.h"#include "GameFramework/SpringArmComponent.h"#include "MyPawn.generated.h"UCLASS()class FIRSTDEMO_API AMyPawn : public APawn{ GENERAT ...
UE4C++ APawn类,添加轴映射,使能够控制APawn移动
APawn类,添加轴映射,使能够控制APawn移动
MyPawn.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"#include "GameFramework/Pawn.h"#include "Components/StaticMeshComponent.h"#include "Camera/CameraComponent.h"#include "MyPawn.generated.h"UCLASS()class FIRSTDEMO_API AMyPawn : public APawn{ GENERATED_BODY()public: // Sets default values for this pawn's properties AMyPawn();protected: // Cal ...
UE4C++ AActor类的创建
创建一个带StaticMeshComponent的AActor类
MyActor.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"#include "GameFramework/Actor.h"#include "MyActor.generated.h" UCLASS() //因为Actor父类就已经是blueprintable ,所以不用在括号里面声明class FIRSTDEMO_API AMyActor : public AActor{ GENERATED_BODY()public: // Sets default values for this actor's properties //构造函数 AMyActor(); //定义组件 VisibleAnywhere 任何地方可见 UPROPERTY(VisibleAn ...
UE4C++ Uobject的创建
MyObject.h
// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"#include "UObject/NoExportTypes.h"#include "MyObject.generated.h"/** * */UCLASS(Blueprintable) //可生成蓝图的class FIRSTDEMO_API UMyObject : public UObject{ GENERATED_BODY()public: //构造函数 UMyObject(); //成员变量 UPROPERTY(BlueprintReadWrite,Category="My Viriables") float test; //成员函数 UFUNCTION(BlueprintCallable,Category="My Function ...
可变分区内存动态分配模拟
C++ 生成 -10 到 30 的随机数
int main() { vector<int> nums; srand((unsigned)time(NULL)); for (int i = 0; i < 20; i++) { nums.push_back(rand()%(41)-10); //生成 -10 到 30 的随机数 } for (int i : nums) { cout << i << " "; } cout << endl; return 0;}
第一次运行结果:第二次运行结果:
Loop & FlowControl
Loop&FlowControl--三种循环方式:while ,for ,repeat...until--循环控制语句:break ,goto 没有continue--1、while循环 --和c,c++的while循环没多大区别, 需要注意的是do end a=10 while(a>5) do print(a) a=a-1; end--2、for循环 --2.1 数值for循环 for i=1,10 do --表示的是从1循环到10 print(i) end --2.2 泛型for循环 泛型 for 循环通过一个迭代器函数来遍历所有值,类似 java中的 foreach 语句。 a={"one","two","three"} for i,v in ipairs(a) do --ipairs是Lua中的迭代器,用于迭代数组,相当于stl中的迭代器 print(i,v) end--3、repeat...until循环 i=15 ...
Lua变量以及赋值,索引操作
Lua变量以及赋值,索引操作--变量类型:全局变量,局部变量,表中的域--[[--Lua 中的变量全是全局变量,那怕是语句块或是函数里,除非用 local 显式声明为局部变量。--局部变量的作用域为从声明位置开始到所在语句块结束。--变量的默认值均为 nila=5 --全局变量local b=6 --局部变量function joke() c=4 --尽管在函数中,也是全局变量,除非用local声明 local d=7endjoke()print(c,d) --输出结果为4 nil ,则local表示的是局部变量,d打印出来的值为nildo local a=6 b=6 --为局部变量重新赋值 print(a,b)enda=3 --为全局变量重新赋值print(a,b)--]]--赋值语句--[[--1,Lua 可以对多个变量同时赋值,变量列表和值列表的各个元素用逗号分开,赋值语句右边的值会依次赋给左边的变量。a,b=6,7print(a,b)--2.交换变量的值 -- x,y=y,x -- ...
Lua 基本数据类型
基本数据类型--type函数 判断数据类型--[[print(type("hello world"))print(type(10.4*3))print(type(print))print(type(type))print(type(true))print(type(nil))print(type(type(x)))--]]--nil类型--[[--nil 表示空值print(type(a)) --打印一个没有赋值的变量,会输出nil--删除变量 ,用nil给变量赋值tab1 = { key1="val1",key2="val2","val3"}for k,v in pairs(tab1) do print(k .."-".. v)endtab1.key1=nilfor k,v in pairs(tab1) do print(k .."-".. v)end--nil做比较时应该加双引号",此话的意思应放在适当情景,转换成相同类 ...
Lua基础
Lua基础初学Lua
print("hello world")print("www.liuzhifeng.com")--单行注释--[[多行注释--]]--[[ 默认状态下,变量总认为是全局的。 给一个变量赋值后即创建了这个变量 删除变量:将其赋值为nil--]]b=10print(b)b=nilprint(b)--当变量为nil时,则变量不存在;当变量不为nil时,则这个变量即存在--设置SCiTE默认编码格式UTF-8:Options->Open User Options File->输入-- code.page=65001-- output.code.page=65001
Lua字符串操作
Lua字符串操作--Lua字符串--[[ 1、stirng.upper(str) 转化为大写 2、string.lower(str) 转化为小写 3、string.gsub(mainStr,findStr,replaceStr,num) 替换字符 print(string.gsub("aaaa","a","z",3)) 4、string.find(Str,substr,(init,[end])) 在目标字符串中搜索从指定索引后的内容(第三个数为索引),返回开始和结束的索引 print(string.find("hello lua user","lua",1)) 5、string.reverse(str) 反转字符串 print(string.reverse("hello")) 6、string.fomat(...) 相当于c中的printf 7、string.char(str) 将整形数字转换为字符并连接 prin ...