在使用unity开发游戏时,都会涉及到一些特效的开发。实际上在QML中也提供了一些可以做特效的控件,称之为粒子系统。本篇博客主要记录一些使用粒子做特效的方式。
特效–火焰效果:
效果展示:
粒子特效1
相关代码:
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import QtQuick.Particles 2.0
ApplicationWindow {
id:root
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
id:rec
width: 300
height: 300
anchors.centerIn: parent
color: "black"
Button {
text: "start"
y: 0
onClicked: {
particles.start() }
}
Button {
text: "pause"
y: 70
onClicked: {
particles.pause() }
}
Button {
text: "resume"
y: 140
onClicked: {
particles.resume() }
}
Button {
text: "stop"
y: 210
onClicked: {
particles.stop() }
}
ParticleSystem {
id:particles; running: false}
ItemParticle {
system: particles
delegate: Rectangle {
id:rectdel
width: 10
height: 10
radius: 10
color: "red"
}
}
Emitter {
system: particles
x:100
width: 200
velocity: PointDirection {
y:300; yVariation: 100 }
}
}
}
效果展示:
雪花特效
相关代码:
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import QtQuick.Particles 2.0
ApplicationWindow {
id:root
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
id:rec
width: 300
height: 300
anchors.centerIn: parent
ParticleSystem {
anchors.fill: parent
ImageParticle {
sprites: Sprite {
//此处用的是sprite图像--存储了图片每一帧的不同姿态
name: "snow"
source: "qrc:/image/imgs/snowflake.png"
frameCount: 51
frameDuration: 40
frameDurationVariation: 8
}
colorVariation: 0.8
entryEffect: ImageParticle.scale
}
Emitter {
emitRate: 20
lifeSpan: 3000
velocity: PointDirection {
y:80; yVariation: 40;}
acceleration: PointDirection {
y:4}
size: 20
sizeVariation: 10
width: parent.width
height: 100
}
}
}
}
效果展示:
火焰特效
相关代码:
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import QtQuick.Particles 2.0
ApplicationWindow {
id:root
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
anchors.fill: parent
color: "#222222"
ParticleSystem {
anchors.fill: parent
ImageParticle {
groups: ["smoke"]
color: "#11111111"
source: "qrc:/image/imgs/butterfly.png"
}
ImageParticle {
groups: ["flame"]
color: "#11ff400f"
colorVariation: 0.1
source: "qrc:/image/imgs/butterfly.png"
}
Emitter {
anchors.centerIn: parent
group: "flame"
emitRate: 120
lifeSpan: 1200
size: 20
endSize: 10
sizeVariation: 10
acceleration: PointDirection {
y:-40 }
velocity: AngleDirection {
angle: 270; magnitude: 20; angleVariation: 22; magnitudeVariation: 5 }
}
TrailEmitter {
group: "smoke"
follow: "flame"
emitRatePerParticle: 1
lifeSpan: 2400
lifeSpanVariation: 400
size: 16
endSize: 8
sizeVariation: 8
acceleration: PointDirection {
y:-40 }
velocity: AngleDirection {
angle: 270; magnitude: 40; angleVariation: 22; magnitudeVariation: 5 }
}
}
}
}
效果展示:
粒子组过渡
相关代码:
import QtQuick 2.2
import QtQuick.Window 2.1
import QtQuick.Controls 2.0
import QtGraphicalEffects 1.0
import QtQuick.Particles 2.0
ApplicationWindow {
id:root
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle {
anchors.fill: parent
color: "#222222"
ParticleSystem {
anchors.fill: parent
ParticleGroup {
name: "unlit"
duration: 1000
to: {
"lighting": 1, "unlit": 5}
ImageParticle {
source: "qrc:/image/imgs/butterfly.png"
color: "#2060160f"
colorVariation: 0.1
}
Emitter {
height: parent.height / 2
emitRate: 4
lifeSpan: 3000
size: 24
sizeVariation: 4
velocity: PointDirection {
x: 120; xVariation: 80; yVariation: 50}
acceleration: PointDirection {
y: 120}
}
}
ParticleGroup {
name: "lighting"
duration: 200
to: {
"lit": 1}
}
ParticleGroup {
name: "lit"
duration: 2000
TrailEmitter {
group: "flame"
emitRatePerParticle: 50
lifeSpan: 200
emitWidth: 8
emitHeight: 8
size: 24
sizeVariation: 8
endSize: 4
}
}
ImageParticle {
groups: ["flame", "lit", "lighting"]
source: "qrc:/image/imgs/butterfly.png"
color: "#00ff400f"
colorVariation: 0.1
}
}
}
}
文章浏览阅读1.9k次,点赞3次,收藏15次。AM、DSB、SSB、FM、包络检波、相干解调_vsb系统仿真
文章浏览阅读1.1w次。介绍如何使用Openssl解析CA证书、获取“密钥用法”和“增强型密钥用法”扩展属性。_openssl 增强型密钥用法
文章浏览阅读3k次,点赞6次,收藏5次。ubuntu18.04在运行sudo apt-get update命令时出现以下错误:E: 仓库 “http://ppa.launchpad.net/fcitx-team/nightly/ubuntu bionic Release” 没有 Release 文件解决办法:打开软件更新>其他软件,将做标记的两个勾选去掉问题解决...
文章浏览阅读1w次,点赞5次,收藏10次。1、 资金账户(证券公司开立的,与券商直接相关)资金账户是你登陆证券交易结算资金账户的凭证,你在一家证券公司开户后,就拥有了这家证券公司的资金账户,你平时用这个账户进行股票的买卖和操作。这是证券公司专门用来记录你资金流转的账户,但是你的资金并不在证券公司里,而是放在和证券公司合作的第三方存管银行账户里,你交易的时候通过交易软件把钱转到你的资金账户进行股票交易,这是为了保护投资者的利益,防止证券公司挪用和非法占有客户的资金。资金账号,是一种股市上的专业术语,一般指的是用于买卖股票的股东资金账户上的账..._证券账户与资金账户与银行账户区别
文章浏览阅读1.1k次。目录说明分解步骤输出示例其他类型的机器简版过程说明在运行 Cisco IOS 系统软件的 Catalyst 6500/6000 和 Cisco 7600 上,其启动顺序与 Cisco 7200 系列路由器有所不同,因为两者的硬件不一样。在您关机并重新开机机箱后,交换机处理器(SP)首先启动。在一小段时间(大约 25 到 60 秒)后,它将控制台所有权转交给路由处理器 (RP (MSFC))。RP 继续加载捆绑的软件映像。请务必在 SP 将控制台控制权转交给 RP 之后立即按 Ctrl-brk。如果您太早_sys-sp-3-logger_flushed system was paused for
文章浏览阅读427次。通过可视化工具建库建表创建数据库CREATE DATABASE studb2 CHAR SET utf8;切换数据库(使用use 将数据库切换到 studb2)USE studb2 ;在studb2 中创建名为t_stu的表CREATE TABLE t_stu( sid VARCHAR(10) , sname VARCHAR(20), age INT, height FLOAT , weight DOUBLE)CHAR SET utf8_头歌实践教学平台数据库用户数据库的创建及删除
文章浏览阅读1.2w次,点赞12次,收藏54次。在学习python的过程中遇到了这两个函数,讲讲学习的心得_unstack函数
文章浏览阅读559次。。。_从txt导入到sqlite
文章浏览阅读521次,点赞25次,收藏11次。包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频**
文章浏览阅读1.5k次。单向图#include//每次找费用的最短路,更新残留网络图直到找不到最短路为止#include//最大费用 权值取负值 结果取负值#include#include#includeusing namespace std;const int inf=0x3f3f3f3f;struct Node_单向图费用流
文章浏览阅读318次。在现代编程世界中,面向对象编程(OOP)语言在改变软件开发中的设计和实现模式方面发挥了进化作用。作为OOP家族的重要成员,Python在过去10年左右逐渐流行起来。与其他OOP语言一样,Python围绕大量不同的对象操作其数据,包括模块、类和函数。如果您有任何OOP语言的编程经验,您应该知道所有对象都有其内部特征数据,称为字段、属性或属性。在Python中,这些对象绑定的特征数据通常称为属性。在本文中,我将特别在自定义类的上下文中讨论它们。1. 类属性为了更好地管理项目中的数据,我们经常需要_python属性的五大类
文章浏览阅读282次。5:系统简介设置:系统管理员应该可以通过系统简介设置功能设置系统前台的系统简介信息,系统前台的系统简介是随后台的变化而变化的,系统简介应该使用编辑器,实现图片,文字,列表,样式等多功能输入。6:系统公告设置:系统管理员应该可以通过系统公告设置功能设置系统前台的系统公告信息,系统前台的系统公告是随后台的变化而变化的,系统公告应该使用编辑器,实现图片,文字,列表,样式等多功能输入。应该都要能修改自己的登录密码,修改后需要重新登录。13:装修效果:员工给客户上传装修效果和装修进度,客户查询。_python抓取装修需求