Beispiel #1
0
 public override void _Ready()
 {
     _currentZoomFactor = DefaultZoom;
     _player            = GetNode <KinematicBody2D>("/root/MainScene/Player");
     _camera            = _player.GetNode <Camera2D>("Camera2D");
     _box       = GetNode <CollisionShape2D>("CollisionShape2D");
     _rectangle = _box.GetShape() as RectangleShape2D;
     _rect      = new Rect2(_box.GlobalPosition - _rectangle.Extents, _rectangle.Extents * 2);
 }
Beispiel #2
0
        public override void _Ready()
        {
            _collisionShape         = GetNode <CollisionShape2D>(collisionShapeNodePath);
            _explosionCollisionArea = GetNode <Area2D>(explosionCollisionAreaNodePath);

            _explosionCollisionArea.Connect("body_entered", this, nameof(HandleBodyEntered));
            _explosionCollisionArea.Connect("body_exited", this, nameof(HandleBodyExited));

            CircleShape2D collisionShape = (CircleShape2D)_collisionShape.GetShape();

            collisionShape.SetRadius(explosionRadius);
        }
        public void SetCollisionRadius(float collisionRadius)
        {
            CircleShape2D collsionShape = (CircleShape2D)_circleCollisionShape.GetShape();

            collsionShape.SetRadius(collisionRadius);
        }