Qt 国庆祝福

前言

本打算利用QML实现魔兽登录界面,结合之前的SRP-6协议简单模拟客户端和服务端的操作;但由于忙,而且QML目前我找了部分qml库,试着写了一点,还是达不到想要的效果,不如自己"造轮子"来得快一点

怀旧服界面如下图所示:

该界面具备以下元素:

1.视频背景

2.粒子特效-不多

3.输入框

4.图片现代按钮-具备一定的特效

5.文字按钮

6.Qt Socket,进行SRP-6协议认证模拟

不知不觉就到国庆了,为了庆祝祖国76周年华诞先写个界面祝福祖国,暂时先将WOW登录界面搁置

一、祝福界面

1.1、设计

  1. 背景图片

  2. 烟花粒子特效

  3. 文字

  4. 声音效果

    由于时间仓促,只能暂时实现这么多

1.2、粒子特效

这次不牵涉到着色器的内容,就使用Qt所支持的粒子系统(particle system)来进行编写;我看CSDN中关于粒子这些各种属性,方法讲解很多,就不在记录,基本就是看官方文档和CSDN中所提供的示例

  • 设置基础粒子
javascript 复制代码
    // 火箭粒子
    ImageParticle {
        system: particleSys
        groups: ["rocket"]
        source: "qrc:///particleresources/glowdot.png"
        color: "gold"
        colorVariation: 0.4
        entryEffect: ImageParticle.Fade
    }

    // 烟雾粒子
    ImageParticle {
        system: particleSys
        groups: ["smoke"]
        source: "qrc:///particleresources/star.png"
        color: "#80ffffff"
        colorVariation: 0.3
        alpha: 0.6
        rotation: 0
        rotationVariation: 180
        rotationVelocity: 45
        entryEffect: ImageParticle.Fade
    }

    // 爆炸粒子
    ImageParticle {
        system: particleSys
        groups: ["explode"]
        source: "qrc:///particleresources/star.png"
        color: Qt.hsla(Math.random(), 0.8, 0.6, 0.9)
        colorVariation: 0.8
        rotation: 0
        rotationVariation: 360
        rotationVelocity: 180
        entryEffect: ImageParticle.Scale
    }
  • 为火箭粒子设置发射器
JavaScript 复制代码
        Emitter {
            id: leftRocketEmitter
            system: particleSys
            group: "rocket"

            x: index * 150 + 100
            y: parent.height - 50
            width: 8
            height: 8

            emitRate: 1
            maximumEmitted: 2
            lifeSpan: 3000
            lifeSpanVariation: 500
            size: 32
            sizeVariation: 8
            endSize: 16

            velocity: AngleDirection {
                angle: 270
                magnitude: 350
                magnitudeVariation: 80
            }

            acceleration: AngleDirection {
                angle: 90
                magnitude: 60
            }
        }
  • 再为发射的火箭设置烟雾
    模拟现实生活中的烟花后面的星光或者烟雾
JavaScript 复制代码
// 烟雾轨迹
    TrailEmitter {
        id: smokeEmitter
        system: particleSys
        emitHeight: 2
        emitWidth: 6
        group: "smoke"
        follow: "rocket"
        emitRatePerParticle: 128
        lifeSpan: 800
        lifeSpanVariation: 200
        size: 20
        sizeVariation: 6
        endSize: 4

        velocity: AngleDirection {
            angle: 90
            angleVariation: 15
            magnitude: 80
        }
    }
  • 再添加部分影响器,模拟现实中的物理运动
JavaScript 复制代码
// 顶部摩擦效果
    Friction {
        groups: ["rocket"]
        anchors.top: parent.top
        width: parent.width
        height: parent.height / 2
        system: particleSys
        threshold: 5
        factor: 0.85
    }

    // 底部湍流效果
    Turbulence {
        groups: ["rocket"]
        anchors.bottom: parent.bottom
        width: parent.width
        height: parent.height / 3
        system: particleSys
        strength: 35
    }

    // 到达顶部时触发爆炸
    GroupGoal {
        id: explosionTrigger
        anchors.top: parent.top
        width: parent.width
        height: parent.height / 6
        system: particleSys
        groups: ["rocket"]
        goalState: "explosion"
        jump: true
    }
  • 烟花爆炸-重头戏
    当火箭上升到某个高度时,触发爆炸效果
JavaScript 复制代码
   // 爆炸粒子组
    ParticleGroup {
        name: "explosion"
        system: particleSys

        TrailEmitter {
            id: explosionEmitter
            group: "explode"
            follow: "rocket"
            lifeSpan: 1500
            lifeSpanVariation: 300
            emitRatePerParticle: 300
            size: 36
            sizeVariation: 12
            endSize: 8

            velocity: AngleDirection {
                angle: -90
                angleVariation: 360
                magnitude: 80
                magnitudeVariation: 50
            }

            acceleration: AngleDirection {
                angle: 90
                magnitude: 40
            }
        }
    }
  • 1.3、最终成果展示


    Code
相关推荐
楚山之石27 分钟前
【Lancet Neurology 】多发性硬化认知障碍的 SDMT 筛查、灰质萎缩标志与认知康复循证路径
图像处理·人工智能·学习·mri
海海不掉头发2 小时前
CSDN博客_时序预测9模型复现对比
人工智能·学习·软件工程
蓝祁子yoky4 小时前
Qt学习日记 Day13:网络编程(一)-TCP基础与Socket实战
网络·qt·学习
架构师伯子明5 小时前
Ros 学习十三:IK Demo
学习
小羊没烦恼!5 小时前
关于分布式锁原理的一些学习与思考-redis分布式锁,zookeeper分布式锁
java·服务器·网络·学习·负载均衡
幼儿园蛋小黄5 小时前
从 STM32N647 的 AI 部署入门嵌入式:一条可落地的学习路线
人工智能·stm32·学习
飞浪纪元[FWC–FE]7 小时前
从零到一键绿:Qt 5.14.2 + VS2019 开发环境搭建、Kit 套件配置与构建错误修复完全手册
开发语言·qt
Y.9997 小时前
电脑黑屏只有鼠标能动
学习
架构师伯子明7 小时前
FFmpeg C++学习(一):编译和demo
开发语言·c++·学习
叼烟扛炮7 小时前
[LangChain] 学习笔记(02):LCEL 链式调用与动态模型配置实战
服务器·开发语言·网络·笔记·学习·langchain