What is the best way to store sprite sheet in dictionary ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pin
:warning: Old Version Published before Godot 3 was released.

I try Atlas Importer but the pixel is not good blurry, So I disable Mipmaps, Repeat, Filter no luck

I was thinking of using

set_region_rect()
this code but it takes alot of time to put Rect2()

var texture = {'rock': [Rect2(x, y, w, h)],
               'tree':[Rect2(x, y, w, h)]}

func _ready():
    set_region(true)
    set_region_rect(texture['rock'][0])

EDIT: I try importing again with Atlas Importer again blurry but when i try restart godot engine BOOM working no more blurry :smiley:

:bust_in_silhouette: Reply From: quijipixel

If your Spritesheet has sprites of the same size, you can just set the quantity of sprites horizontally or vertically using set_hframes() or set_vframes(). If your sprite sheet (for example) has 10 columns of sprites callset_hframes(10)and the Sprite node will calculate the frames. After that, just use the method set_frame(n) to tell the Sprite node which one to show. Notice that n goes from 0 to your number of sprites ordered by columns.

Then your dictionary will be:

var textures = {
    rock = 0,
    tree = 1
}

func _ready()
    set_frame(textures.rock)

Thank you for your answer :smiley:

Pin | 2017-08-22 05:35

Your welcome! :wink:

quijipixel | 2017-08-22 09:52