コード例 #1
0
        /// <summary>
        /// Initialize the emitter with a texture for particles.
        /// </summary>
        /// <param name="particleTexture">Texture used for particles.</param>
        public void Initialize(Texture2D particleTexture)
        {
            _texture = particleTexture;
            _particleConfiguration.Width  = _texture.Width;
            _particleConfiguration.Height = _texture.Height;

            YnParticle particle  = null;
            Vector2    direction = Vector2.Zero;
            Rectangle  rectangle = new Rectangle((int)_position.X, (int)_position.Y, _texture.Width, _texture.Height);

            for (int i = 0; i < _maxParticles; i++)
            {
                direction = YnRandom.GetVector2(
                    _direction.X - _rotation / 2,
                    _direction.X + _rotation / 2,
                    _direction.Y - _rotation / 2,
                    _direction.Y + _rotation / 2);

                particle = new YnParticle(_texture, rectangle, direction, 500);
                _particles.Add(particle);
            }
        }
コード例 #2
0
ファイル: YnEmitter.cs プロジェクト: shaoleibo/YnaEngine
        /// <summary>
        /// Initialize the emitter with a texture for particles.
        /// </summary>
        /// <param name="particleTexture">Texture used for particles.</param>
        public void Initialize(Texture2D particleTexture)
        {
            _texture = particleTexture;
            _particleConfiguration.Width = _texture.Width;
            _particleConfiguration.Height = _texture.Height;

            YnParticle particle = null;
            Vector2 direction = Vector2.Zero;
            Rectangle rectangle = new Rectangle((int)_position.X, (int)_position.Y, _texture.Width, _texture.Height);

            for (int i = 0; i < _maxParticles; i++)
            {
                direction = YnRandom.GetVector2(
                    _direction.X - _rotation / 2,
                    _direction.X + _rotation / 2,
                    _direction.Y - _rotation / 2,
                    _direction.Y + _rotation / 2);

                particle = new YnParticle(_texture, rectangle, direction, 500);
                _particles.Add(particle);
            }
        }