您的位置:首页 > 财经 > 产业 > 网页微博草稿箱在哪_北京 seo_企业网站的在线推广方法有_外贸seo推广公司

网页微博草稿箱在哪_北京 seo_企业网站的在线推广方法有_外贸seo推广公司

2025/4/30 4:40:41 来源:https://blog.csdn.net/wunan233/article/details/147594477  浏览:    关键词:网页微博草稿箱在哪_北京 seo_企业网站的在线推广方法有_外贸seo推广公司
网页微博草稿箱在哪_北京 seo_企业网站的在线推广方法有_外贸seo推广公司

在这里插入图片描述

今日用时2h27min
最近在入门UEC++,然后选了一个简单的愤怒的小鸟来入门,这是一个合集,想看的朋友可以关注一下,到时候做完了会分享我的工程文件~~

1.资产导入

在fiber游戏制作中,需确保小鸟角色成功导入并能实现动画效果。具体步骤如下:

​ ● 资产转换

​ ○ 选中所有纹理资产。

​ ○ 右键选择“创建精灵”,将所有资产转换为精灵形式。

​ ○ 保存转换后的精灵资产。

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

​ ● 动画制作

​ ○ 新建文件夹命名为“animal”。

​ ○ 在Paper 2D模块中,选择“序列图”以创建帧动画。

​ ○ 命名序列为“红鸟”,创建红鸟的动画序列。

在这里插入图片描述

​ ● 帧编辑与播放

​ ○ 在编辑器面板中,为红鸟添加三帧动画。

​ ○ 依次选择每个帧对应的精灵,完成动画帧的设置。

​ ○ 调整动画播放速度,如将默认的一秒钟15帧调整为一秒钟8帧。

​ ○ 调整每帧持续的时间,就有一种动画的感觉了。

小鸟对象

在UEC++中出来这些对象的头文件和cpp文件之外,在虚幻里面做2D游戏的时候记得加载这个插件:Paper2D,不然很容易报错。

外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传

在UE中创建C++对象

1.BgActor

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "BgActor.generated.h"class UPaperSpirteComponent;
UCLASS()
class FLYBIRD_API ABgActor : public AActor
{GENERATED_BODY()public:	// Sets default values for this actor's propertiesABgActor();void RandomBgSprite();protected:// Called when the game starts or when spawnedvirtual void BeginPlay() override;public:	// Called every framevirtual void Tick(float DeltaTime) override;
protected:UPROPERTY()UPaperSpirteComponent* BGRenderComp;
};
// Fill out your copyright notice in the Description page of Project Settings.#include "BgActor.h"
#include <PaperSpriteComponent.h>// Sets default values
ABgActor::ABgActor()
{// Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.PrimaryActorTick.bCanEverTick = false;}	
void ABgActor::RandomBgSprite()
{ }// Called when the game starts or when spawned
void ABgActor::BeginPlay()
{Super::BeginPlay();RandomBgSprite();}// Called every frame
void ABgActor::Tick(float DeltaTime)
{Super::Tick(DeltaTime);}

2.BirdPawn

// Fill out your copyright notice in the Description page of Project Settings.#pragma once#include "CoreMinimal.h"
#include "GameFramework/Pawn.h"
#include "BirdPawn.generated.h"class UPaperFlipbookComponent;
class UCameraComponent;UCLASS()
class FLYBIRD_API ABirdPawn : public APawn
{GENERATED_BODY()public:// Sets default values for this pawn's propertiesABirdPawn();protected:// Called when the game starts or when spawnedvirtual void BeginPlay() override;void DoFly();
public:	// Called every framevirtual void Tick(float DeltaTime) override;virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;protected:// 指针为什么需要类型? 表示所指向空间 的类型。// 所有指针的大小是一样的 类型是空间的解释方式UPROPERTY(VisibleAnywhere)UPaperFlipbookComponent* BirdRenderComp;UPROPERTY(VisibleAnywhere)UCameraComponent* PlayerCamera;};

设置组件的依附关系以及相机的投射模式


#include "BirdPawn.h"
#include <PaperFlipbookComponent.h>
#include <Camera/CameraComponent.h>
#include "Components/StaticMeshComponent.h"  
#include "PaperFlipbook.h"
// Sets default values
ABirdPawn::ABirdPawn()
{PrimaryActorTick.bCanEverTick = true;// 为当前对象添加根组件RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComp"));// 创建组件的方法BirdRenderComp = CreateDefaultSubobject<UPaperFlipbookComponent>(TEXT("BirdRenderComp"));// 加到pawn身上BirdRenderComp->SetupAttachment(RootComponent);// 构建相机组件PlayerCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("PlayerCamera"));// 添加相机依附关系PlayerCamera->SetupAttachment(RootComponent);//调整相机旋转PlayerCamera->SetRelativeRotation(FRotator(0, -90, 0)); // 调整相机的投射模式PlayerCamera->SetProjectionMode(ECameraProjectionMode::Orthographic);// 调整相机位置PlayerCamera->SetRelativeLocation(FVector(0, 100, 0));// 调整视口宽度PlayerCamera->SetOrthoWidth(1000.0f);// 加载资产ConstructorHelpers::FObjectFinder<UPaperFlipbook> BirdBookObj(TEXT("PaperFlipbook'/Game/FlyBird/Textures/Anima/Birds/PF_RedBird.PF_RedBird'"));BirdRenderComp->SetFlipbook(BirdBookObj.Object);}void ABirdPawn::BeginPlay()
{Super::BeginPlay();//ACTOR的旋转缩放从根组件里面来的}void ABirdPawn::DoFly()
{UE_LOG(LogTemp, Log, TEXT("DoFly"));
}void ABirdPawn::Tick(float DeltaTime)
{Super::Tick(DeltaTime);}void ABirdPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{Super::SetupPlayerInputComponent(PlayerInputComponent);//绑定输入事件PlayerInputComponent->BindAction(TEXT("DoFly"), IE_Pressed, this, &ABirdPawn::DoFly);}

今天遇到的问题

主要会遇到几个报错,就是指针指向的问题,新手经常把命名搞过,set了一个组件给的时候把命名弄错了,所以一定要记得引入库文件。

  1. FObjectFinder 需要一个继承自 UObject 的类型,而 UPaperFlipbook 确实是继承自 UObject 的,但编译器似乎无法正确推断类型。

    • 我解决这个问题是

      确保你包含了 PaperFlipbook 的头文件,并且路径正确。通常情况下,UPaperFlipbook 的头文件是:

      #include "PaperFlipbook.h"
      

总结

今天主要是项目初始化以及通过存C++把对象加入到屏幕上边,以及设置基础的游戏模式。

这里是每天回答三个问题

如果觉得对你有帮助的话麻烦点一个免费的赞

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com