Particle System(粒子系统)

Particle System

I’m sure you will have played many games where effects, such as smoke and fire, are used.There are two ways to create these effects.The first is to use sprite animation, and the second is to use a particle emitter.To use a sprite animation, you would need to create an umber of frames for each phase of the effect and then play them back in sequence.This sprite animation technique was popularized by arcade games over 20 years ago and is stillin use by game developers today.

However, today’s desktops and console games pack powerful CPUs and GPUs that we could only dream of back then. Even the iPhone packs more processor and graphicalpunch than early arcade games. Rather than employing 20-year-old technology, we can create a particle system to animate effects in real time.


The term “particle system” refers to a technique that enables you to simulate certain organic behaviors, such as fire, smoke, moving water, rain, and snow. A particle system enables you to configure the number of particles you want to generate and how you wouldlike them to move, including the following:

1. Their speed

2. Their lifespan(生命时间)
Even with these simple settings, it is possible to create some impressive effects with a par
ticle system. 


What Is a Particle?

You may be wondering what we mean when we say particle. Don’t think of it in terms of atoms or quarks like you would in a physics class. When it comes to game development, what we really mean when we say “particle” is “image”. Each “particle” is in fact an image that is rendered to the screen at the particle’s current location with the particle’s size and color. The image could be a simple circle, a star, or what ever you want, just as long as it gives you the effect you are looking for.

A particle system normally has a particle emitter.The emitter is responsible for generating new particles and tracking their progress through their life before removing them when they die.When a particle is created, the particle emitter sets some parameters, including the following:

1. Speed: The speed at which the particle moves.

2. Life span: The amount of time a particle will live for. Each cycle through the gameloop causes the particles lifespan to reduce until it reaches 0.The particle is then removed from the update list.

3. Direction: The direction that particle will move.This direction could change overtime based on other settings such as gravity(重力).

4. Start color: The color the particle will have when it is created.
5. End color: The color the particle should have when it reaches the end of its life cycle.n Size: The size of the particle.

Although the particle emitter will ask each particle to update itself, it is the particle’s responsibility to track its own position, color, life span, and so on.This allows each particle to move independently of each other. Add to this a level of randomness, and it is possibleto create very organic looking effects, such as fog and smoke.

You’ll see how to create a particle system in Chapter 10,“The Particle Emitter.”

As with tile maps, it is possible to configure particle emitters manually, but this can tak eup a lot of time. It certainly speeds things up to use a visual editor for creating these effects, such as Particle Designer.9 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值