how to randomize backgrounds?

famekraftsfamekrafts Member, BASIC Posts: 834
edited October 2012 in Working with GS (Mac)
I have different backgrounds and I would like to randomize them for different levels.

For example, each level starts with a random background.

currently I am using random(1,4)

if 1 change image to bg 1

if 2 change to bg 2 .... and so on

The problem is it takes some loading time when the level icon is clicked from the main menu

and when changing directly between stages, it first shows the original bg and then after a sec changes randomly to another background even though the timer is 00 secs. This change doesn't look good.

Is there a better and fast way to get this done?



Comments

  • KangavarkKangavark Member Posts: 62
    I believe there's a Tshirtbooth video tutorial about using tables to load random images. I don't have the link handy though. You'd need to do a change image behavior tied to some triggering rule that refers to image names that are loaded into a table.
  • famekraftsfamekrafts Member, BASIC Posts: 834
    Thanks, will try to find it.
  • gamesfuagamesfua Member Posts: 723
    The only thing i can add to this is if you're still having a problem with the background switching as it loads- you may want to put a loading splash screen over the level. Why? This will allow the level background to change behind it without the user seeing the switch (which can look possibly unprofessional). By loading splash screen i mean a low res full screen image that covers the entire level at the start of each level. Have a rule after .5 seconds or whatever to move off screen. Hope this helps.
  • famekraftsfamekrafts Member, BASIC Posts: 834
    Thanks, I was also thinking to talk about my other games inside the game, there is no better way to do it then using loading screens.
  • famekraftsfamekrafts Member, BASIC Posts: 834
    edited October 2012
    But will I be able to use low resolution for a HD game? Am I not supposed to use double size?

    I am facing size problem as well, being HD the size of one bg is going to 3mb a jpeg files.

    I am not sure whether png files are smaller in size than jpeg or not when imported inside GS?

    I imported 4 jpeg images into GS, my size jumped from 27mb to 37 mb and app size is about 49 mb.

    Is this size fine for a HD game?
  • gamesfuagamesfua Member Posts: 723
    Double size for retina. As for graphics try to use ImageOptim for mac if you can. It will really bring down file size. Correct me if i'm wrong but its sometimes best to import pngs into gs instead of gs converting for you. Why? Because you will have control over how its manipulated to get smaller in size. Try imageoptim!
  • famekraftsfamekrafts Member, BASIC Posts: 834
    I am new to GS, making my first game so no idea what will work best. Everything else is png just the jpeg for BG because the png size was going 3mb, almost double of jpeg. Will try imageoptim.
  • famekraftsfamekrafts Member, BASIC Posts: 834
    Search in the app store is only giving me png compressor by some shpakovski.com.

    Has the app name changed ?
  • MeaningfulGamesMeaningfulGames Member, PRO Posts: 171
    you could make an actor that covers the whole size of your background, and make if
    yourvariable = 1,2, 3, 4... (randomise it wherever you want) then change self.image to whatever png. make sure in your expression editor you do speech marks like this ""YourImageName"..".png" or it won't find it.
  • famekraftsfamekrafts Member, BASIC Posts: 834
    you could make an actor that covers the whole size of your background, and make if
    yourvariable = 1,2, 3, 4... (randomise it wherever you want) then change self.image to whatever png. make sure in your expression editor you do speech marks like this ""YourImageName"..".png" or it won't find it.
    Ok will try it. why separating the .. png ?
  • gamesfuagamesfua Member Posts: 723
    Here's a link to imageoptim btw. hope it helps!
    http://imageoptim.com
  • famekraftsfamekrafts Member, BASIC Posts: 834
    Thanks got it.
  • famekraftsfamekrafts Member, BASIC Posts: 834
    edited October 2012
    ok while putting these loading screen which attribute shoud I use keeping the loading in mind as its needs to be intantaneous

    constrain attribute

    spawning of the loading image

    or interpolate?

    spawning is the only thing which is working right now. Not sure if it will take extra seconds.
  • gamesfuagamesfua Member Posts: 723
    I would just have the load image already on top of the screen. Then TIMER after x change position x and y of load image to off screen.
  • gamesfuagamesfua Member Posts: 723
    Just to be clear i'm talking about a load screen that sits atop the background of a new level. This will hide the background swapping problem you were talking about (and or a temporary fix).
  • famekraftsfamekrafts Member, BASIC Posts: 834
    The problem is the loading takes time when I click the button on the stage select scene, when scene loads it just takes a sec for it to start. So if I keep it only on the stage scene, it will go away instantly.

    For a smooth transition I need to spawn the loading scene on the stage scene as well, so player doesn't know any changes occurring while loading and after loading.

    Aim now is to display some message on the loading screen as well, about the full game and other stuff.

  • famekraftsfamekrafts Member, BASIC Posts: 834
    Got it done with spawning. It get auto destroyed after half a second.
  • gamesfuagamesfua Member Posts: 723
    And you're sure it's not best to just have the LOADING screen be on the screen at the start of the next level instead of spawning it? Spawning taxes the devices ram and may cause little performance issues. Anyways, if it's working for you then keep at it! :)
    How did that imageoptim work? Help you out at all? hope so!
  • famekraftsfamekrafts Member, BASIC Posts: 834
    edited October 2012
    Its working fine on the Mac, I still have to test on the ipad.

    imageoptim works, but for some reason for few images its reducing about 12 - 16% size while for some just 0.1 %, very weird, but at least few mbs will get saved. Thanks
Sign In or Register to comment.