random() 정적인 개인적인 메소드

Internal random float from 0 to 1
static private random ( ) : float
리턴 float
예제 #1
0
        public override void update()
        {
            base.update();
            if (scale.x < 1)
            {
                scale.x = 1;
            }
            if (scale.y < 1)
            {
                scale.y = 1;
            }
            if (flickering)
            {
                alpha = FlxG.random();
            }

            if ((velocity.x != 0) || (velocity.y != 0))
            {
                moving = true;
            }
            else
            {
                moving = false;
            }
        }
예제 #2
0
        /**
         * This function can be used both internally and externally to emit the next particle.
         */
        public void emitParticle()
        {
            FlxPoint    t        = target.getMidpoint();
            FlxParticle particle = recycle(typeof(FlxBasic)) as FlxParticle;

            particle.minSpeed   = minParticleSpeed;
            particle.maxSpeed   = maxParticleSpeed;
            particle.lifespan   = lifespan;
            particle.elasticity = bounce;
            if (target != null)
            {
                particle.reset(t.x, t.y);
            }
            else
            {
                particle.reset(x - (Convert.ToInt32(particle.width) >> 1) + FlxG.random() * width, y - (Convert.ToInt32(particle.height) >> 1) + FlxG.random() * height);
            }
            particle.visible = true;
            particle.drag.x  = particleDrag.x;
            particle.drag.y  = particleDrag.y;
            particle.onEmit();
        }
예제 #3
0
        // update camera scroll in here
        // make sure it stays within bounds
        public override void update()
        {
            //zooming = FlxG.zoom;
            //rotating = FlxG.rotation;
            //follow closely or check deadzones
            if (target != null)
            {
                if (deadzone == null)
                {
                    focusOn(target.getMidpoint());   //add getMidpoint() for FlxObjects
                }
                else
                {
                    //FlxG.log("deadzone is not null");
                    float edge;
                    float targetX = FlxU.ceil(target.x + ((target.x > 0) ? 0.0000001f : -0.0000001f));
                    float targetY = FlxU.ceil(target.y + ((target.y > 0) ? 0.0000001f : -0.0000001f));

                    edge = targetX - deadzone.x;
                    if (scroll.x > edge)
                    {
                        scroll.x = edge;
                    }
                    edge = targetX + target.width - deadzone.x - deadzone.width;
                    if (scroll.x < edge)
                    {
                        scroll.x = edge;
                    }

                    edge = targetY - deadzone.y;
                    if (scroll.y > edge)
                    {
                        scroll.y = edge;
                    }
                    edge = targetY + target.height - deadzone.y - deadzone.height;
                    if (scroll.y < edge)
                    {
                        scroll.y = edge;
                    }

                    //SHAKE
                }
            }

            //make sure we didnt go outside camera's bounds
            if (bounds != null)
            {
                //FlxG.log("bounds is not null");
                if (scroll.x < bounds.left)
                {
                    scroll.x = bounds.left;
                }
                if (scroll.x > bounds.right - width)
                {
                    scroll.x = bounds.right - width;
                }
                if (scroll.y < bounds.top)
                {
                    scroll.y = bounds.top;
                }
                if (scroll.y > bounds.bottom - height)
                {
                    scroll.y = bounds.bottom - height;
                }
            }

            //update effects

            //shake
            if (_fxShakeDuration > 0)
            {
                _fxShakeDuration -= FlxG.elapsed;
                if (_fxShakeDuration <= 0)
                {
                    _fxShakeOffset.make();
                    if (_fxShakeComplete != null)
                    {
                        _fxShakeComplete();
                    }
                }
                else
                {
                    if ((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_HORIZONTAL_ONLY))
                    {
                        _fxShakeOffset.x = (FlxG.random() * _fxShakeIntensity * width * 2 - _fxShakeIntensity * width) * _zoom;
                    }
                    if ((_fxShakeDirection == SHAKE_BOTH_AXES) || (_fxShakeDirection == SHAKE_VERTICAL_ONLY))
                    {
                        _fxShakeOffset.y = (FlxG.random() * _fxShakeIntensity * height * 2 - _fxShakeIntensity * height) * _zoom;
                    }
                }
            }


            scroll.x -= _fxShakeOffset.x;
            scroll.y -= _fxShakeOffset.y;

            if (zooming < 1)
            {
                zooming = 1;
            }
        }