Forcing layer graphics via Hash

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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
 

TheoAllen

Self-proclaimed jack of all trades
Veteran
Joined
Mar 16, 2012
Messages
5,592
Reaction score
6,522
First Language
Indonesian
Primarily Uses
RMVXA
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
 

♥SOURCE♥

Too sexy for your party.
Veteran
Joined
Mar 14, 2012
Messages
693
Reaction score
411
Primarily Uses
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.
 

nio kasgami

VampCat
Veteran
Joined
May 21, 2013
Messages
8,949
Reaction score
3,042
First Language
French
Primarily Uses
RMMV
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 

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!
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,050
Members
137,571
Latest member
grr
Top