Get_width() get_height() on sprite 2d

func Item_anim(item):
	match item:
		"poke_ball":
			res.position = player.global_position
			res.texture = load("res://assets/items/poke_ball.png")
			res.scale = Vector2(2,2)
			res.show()
			var tween = get_tree().create_tween()
			tween.tween_property(res,"position",enemy.global_position,1)
			var tweene = get_tree().create_tween()
			tweene.tween_property(res,"rotation",360,1)
			await get_tree().create_timer(1).timeout
			print(enemy.frame_coords)
			var x = enemy.get_width()
			x = x / 2
			var y = enemy.get_height()
			y = y / 2
			res.hide()
			await get_tree().create_timer(.2).timeout
			res.position = Vector2(x,y)
			res.show()
			var tweenw = get_tree().create_tween()
			tweenw.tween_property(res,"position",res.position.y + 20,1)
			await get_tree().create_timer(1).timeout
			res.hide()
			res.scale = Vector2(1,1)

see what im going for

No, I don’t know what you’re going for (you didn’t explain it). But answering the question I assume from title, this is how you get width and height from a sprite.

var width = sprite_2d.get_rect().size.x
var height = sprite_2d.get_rect().size.y

1 Like

the poke ball disappearing then reappearing in the middle of the enemy’s sprite sorry should of made that more clear and thanks

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.