Forcing layer graphics via Hash

● ARCHIVED · READ-ONLY
Started by nio kasgami 4 posts View original ↗
  1. Hi I work on a title screen and I wanted to know how I can exemple making  "Layers" in my title screen 

    In simple I want to offer to people to having a unlimeted amount of picture he can dispose in title screen

    the configuration I want to make is like this 

    Layers = {# layer number => [ "layers filename",ox,oy,movement_x,movement_y,movement_angle,animated,refresh if out of viewport ],1 => ["layers1",10,10,0,0,0, false,true ],}but its how to force the input of the layers I don't know the rest I can handle this by myself but the specific spot is

    "force them to put on the screen"

    thanks for your further answer
  2. You can do

    @sprites = []Layers.each do |layer_num, data| spr = Sprite.new spr.z = layer_num # define other data here @sprites << sprendYou should include the instruction that the layer number should be number (obviously) and need to be different each other
  3. Hello there, nio.

    Why do you want to use hashes? An array would work just fine:

    Layers = [ ['background', 0, 0, 4, 0, 0, false, false], ['layers1', 10, 10, 0, 0, 0, false, true]]Then you would just need to iterate through it and create the layers, maintaining the order thanks to the element index in the array:

    @layers = []Layers.each { |layer| sprite = Sprite.new sprite.bitmap = Cache.picture(layer[0]) # Pushes Sprite object and layer data into the layers container. @layers << [sprite, layer]}Then, you would have to update each one accordingly to the information saved alongside the Sprite.

    @layers.each { |layer| sprite, file, ox, oy, movex, movey, move_ang, anim, refr = *layer # Do your stuff using that information.}Cheers.
  4. TheoAllen said:
    You can do

    @sprites = []Layers.each do |layer_num, data| spr = Sprite.new spr.z = layer_num # define other data here @sprites << sprendYou should include the instruction that the layer number should be number (obviously) and need to be different each other
    haha sure I will specify how to use the layers but thanks for sharing but I will take Science method  : 3 

    ❤SCIENCE❤ said:
    Hello there, nio.

    Why do you want to use hashes? An array would work just fine:

    Layers = [ ['background', 0, 0, 4, 0, 0, false, false], ['layers1', 10, 10, 0, 0, 0, false, true]]Then you would just need to iterate through it and create the layers, maintaining the order thanks to the element index in the array:

    @layers = []Layers.each { |layer| sprite = Sprite.new sprite.bitmap = Cache.picture(layer[0]) # Pushes Sprite object and layer data into the layers container. @layers << [sprite, layer]}Then, you would have to update each one accordingly to the information saved alongside the Sprite.

    @layers.each { |layer| sprite, file, ox, oy, movex, movey, move_ang, anim, refr = *layer # Do your stuff using that information.}Cheers.
    ho my thanks this seem far more logic then my old method who was really messy and I used hash because i how I learned by check moghunter script so...

    and Hash and array are two things I have big difficulty for the moment but thanks I will be sure to thanks you for this!

    -------------------------------------------------------------------------------------------------------

    thanks you people you remove a lot in pain in the back by helping me : 3 !

    now I can concentrate on other stuff!