Skip to main content
Grammar and punctuation, removed redundancy
Source Link
Gnemlock
  • 5.3k
  • 5
  • 28
  • 59

How todo I decrease the scale down (decrease size) of an instanced Node/Scenenode or scene?

I'm trying to decrease size of instanced RigidBody2DRigidBody2D scene, through code.

  With "scale()" methodscale(), I'm trying to decrease the size of the image/sprite that's attached to the RigidBody2DRigidBody2D. The problem is, it's not working.

No matter how much I try to scale down, the size of the blood drop circle remains the same.

Why is this?

This is my example code.

 
const blood_druple_scn = preload("res://Scenes/blood.tscn")

func spawnBlood():
    var newBlood = Blood_druple_scn.instance()
    
    rotationAdd = rotationAdd + 30
    
    if(switchBloodSize == 0):
        set_scale(Vector2(2,1)) //This part is my problem
        print("blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 1
    
    elif(switchBloodSize == 1):
        newBlood.scale(Vector2(0.5,0.5)) //This part is my problem
        print("Blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 0
    
    newBlood.set_pos(Vector2(100,100))
    rotate(rotationAdd)

As you can see, I have 2two different Ifif conditions, each with a different scale()scale() and size. Sadly they are, both remain the same size even tho I gave different values to each of them.

Strange The strange part is, that it does print thatdisplay the scale values hasas been altered. So I guess Blood, yet the newBlood instance isn'tis not visually changing. Why is this?

How to scale down (decrease size) of an instanced Node/Scene?

I'm trying to decrease size of instanced RigidBody2D scene through code.

  With "scale()" method I'm trying to decrease the size of the image/sprite that's attached to the RigidBody2D. The problem is, it's not working.

No matter how much I try to scale down, the size of the blood drop circle remains the same.

Why is this?

This is my example code.

const blood_druple_scn = preload("res://Scenes/blood.tscn")

func spawnBlood():
    var newBlood = Blood_druple_scn.instance()
    
    rotationAdd = rotationAdd + 30
    
    if(switchBloodSize == 0):
        set_scale(Vector2(2,1)) //This part is my problem
        print("blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 1
    
    elif(switchBloodSize == 1):
        newBlood.scale(Vector2(0.5,0.5)) //This part is my problem
        print("Blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 0
    
    newBlood.set_pos(Vector2(100,100))
    rotate(rotationAdd)

As you can see I have 2 different If conditions each with different scale() size. Sadly they are both remain the same size even tho I gave different values to each of them.

Strange part is, it does print that the scale values has been altered. So I guess Blood instance isn't visually changing.

How do I decrease the scale of an instanced node or scene?

I'm trying to decrease size of instanced RigidBody2D scene, through code. With scale(), I'm trying to decrease the size of the image/sprite that's attached to the RigidBody2D. The problem is, it's not working.

No matter how much I try to scale down, the size of the blood drop circle remains the same.

 
const blood_druple_scn = preload("res://Scenes/blood.tscn")

func spawnBlood():
    var newBlood = Blood_druple_scn.instance()
    
    rotationAdd = rotationAdd + 30
    
    if(switchBloodSize == 0):
        set_scale(Vector2(2,1)) //This part is my problem
        print("blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 1
    
    elif(switchBloodSize == 1):
        newBlood.scale(Vector2(0.5,0.5)) //This part is my problem
        print("Blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 0
    
    newBlood.set_pos(Vector2(100,100))
    rotate(rotationAdd)

As you can see, I have two different if conditions, each with a different scale() and size. Sadly, both remain the same size. The strange part is that it does display the scale values as been altered, yet the newBlood instance is not visually changing. Why is this?

Source Link
Kil'jaeden
  • 141
  • 1
  • 3

How to scale down (decrease size) of an instanced Node/Scene?

I'm trying to decrease size of instanced RigidBody2D scene through code.

With "scale()" method I'm trying to decrease the size of the image/sprite that's attached to the RigidBody2D. The problem is, it's not working.

No matter how much I try to scale down, the size of the blood drop circle remains the same.

Why is this?

This is my example code.

const blood_druple_scn = preload("res://Scenes/blood.tscn")

func spawnBlood():
    var newBlood = Blood_druple_scn.instance()
    
    rotationAdd = rotationAdd + 30
    
    if(switchBloodSize == 0):
        set_scale(Vector2(2,1)) //This part is my problem
        print("blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 1
    
    elif(switchBloodSize == 1):
        newBlood.scale(Vector2(0.5,0.5)) //This part is my problem
        print("Blood size: ", newBlood.get_scale())
        add_child(newBlood)
        switchBloodSize = 0
    
    newBlood.set_pos(Vector2(100,100))
    rotate(rotationAdd)

As you can see I have 2 different If conditions each with different scale() size. Sadly they are both remain the same size even tho I gave different values to each of them.

Strange part is, it does print that the scale values has been altered. So I guess Blood instance isn't visually changing.