GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

«1

Comments

  • JGary321JGary321 Posts: 1,246Member
    "Set image sizes with a power of 2 rule. e.g. 32×32, 32×64, 1024×512, etc"

    Hey CodeMonkey, how much does this affect performance? I don't think I've been doing this. Also for clarification, is it the original "Image" or the "Actor" we need to keep like this.
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    Its the original image, and the actor would need to have similar dimensions.
    Its more for iPhone games and its more important for graphics intensive games and larger images. Images are rounded up to the next power of 2 so if you had an original image of 255x511 it is rounded up to 256x512. But if you had an original image of 513x257, it is rounded up to 1024x512 which is a lot of memory wasted.

    So if you had 5x5 images, its not really worth scaling your image down to 4x4.
  • JGary321JGary321 Posts: 1,246Member
    Also for further clarification:

    When you say power of 2 you mean that the width can evenly be divided into length or vise-versa also. Is that correct? For instance

    25 x 50 - power of 2
    26 x 50 - not a power of 2 (this would be rounded to 100 x 50??)

    100 x 50 - power of 2
    200 x 50 - power of 2
    1000 x 50 - power of 2

    Are these all correct? I just don't want any wasted memory =)
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    power of 2 as in, 1,2,4,8,16,32,64,128,256,512,or 1024. Anything higher iPhone does not accept. And these are for width and length separately.

    2x1024 - power of 2 rule.
    30x60 - not power of 2 and will be rounded to 32x64
    258x7 - not power of 2 and will be rounded to 512x8
  • JGary321JGary321 Posts: 1,246Member
    Ahh, I completely understand now. Awesome thank you. I gotta make sure I follow those guidelines. Thanks CodeMonkey.
  • butterbeanbutterbean Posts: 4,315Member, PRO
    This only applies to actors, and not backgrounds right? Or does this rule apply do backgrounds?

    So if I wanted a background of length greater than 1024, would that be an issue?
  • JGary321JGary321 Posts: 1,246Member
    I think the max recommended for backgrounds is for 1024.
  • butterbeanbutterbean Posts: 4,315Member, PRO
    So what if you want to create a platformer, and the width is longer than 1024? Do you copy the image that is 1024 over and over to create a scrolling background that is > than 1024? Like discussed in looping a background?
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    Specifically, its the images you add to the project. So even if you had a drawing of a very long dragon, please limit its size of either/both dimensions to 1024. Break the image up into smaller pieces as needed.
  • butterbeanbutterbean Posts: 4,315Member, PRO
    So background images or foreground images are excluded from this rule then. What is the recommended maximum height or maximum length for a foreground/background image? Or can you extend it to whatever you want?

    :)
  • background/foreground images are not excluded. All images are included in the "rule". Its just the loading of the images that can waste memory when it is rounded up to the next power of 2. So you can have a 2x2 pixel image that you import into the project and make it the image for a 1000x1000 actor (not that I am recommending this), but it doesn't waste the memory that adding a 600x600 pixel image would as the image dimensions will be made to be 1024x1024 pixel image with transparencies.

    Images are limited to 1024 pixels in either dimension.
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    background/foreground images are not excluded. All images are included in the "rule". Its just the loading of the images that can waste memory when it is rounded up to the next power of 2. So you can have a 2x2 pixel image that you import into the project and make it the image for a 1000x1000 actor (not that I am recommending this), but it doesn't waste the memory that adding a 600x600 pixel image would as the image dimensions will be made to be 1024x1024 pixel image with transparencies.

    Images are limited to 1024 pixels in either dimension.
  • JGary321JGary321 Posts: 1,246Member
    Hrmm CodeMonkey = GendaiGames?? I just looked at this post & it was posted by GendaiGames & now it is CodeMonkey. I see through your magical disguise!
  • beatragebeatrage Posts: 126Member
    CodeMonkey

    so as I am using a background image of 2880x320 do you recommend me to change for 1024x320??

    so if I want to have a scene with a background as large as 2880 it´s better to have a background with multiple tiles on it??
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    Not all computers are created equal. On my machine, I am unable to see images greater than 2048 in a single dimension in GameSalad.

    As for the 1024 size limit, I've been told that even though you can see images larger than that, the iPhone scales down the image so you have a bad quality image and essentially a waste in memory.

    CodeMonkey < GendaiGames. GendaiGames is our highest level access account that a few of us share to moderate the forums. I just forgot to log out and login as CodeMonkey.

    Head Chefs and Administrators are us. Sous Chefs are non-Gendai Games users who we have "upgraded" their status for one reason or another.
  • butterbeanbutterbean Posts: 4,315Member, PRO
    How do you "upgrade" your status on GameSalad? Is there a charge, and what does upgrading your status offer?
  • beatragebeatrage Posts: 126Member
    so it´s better to break all the objects from my background (as they are going to reduce the size) and start populating my scene with this objects righ?

    how many objects of the same instance/actor I can repeat at the same scene...is there a limit for this?

    and if I choose a background scene color in blue without using a background tile actor colored in blue ,will it display the color on iphone??

    thanks for the answers CodeMonkey!
  • CodeMonkeyCodeMonkey Posts: 1,803Head Chef, Member, PRO
    Sous Chefs have been "upgraded" depending on what they have done. The charge is that they have posted awesome games, really helped out answering questions, or other things we deem useful for upgrading.

    beatrage,
    The number of objects on a scene is more limited by how complex their behavior lists are. If you have actors with lots of behaviors, you won't be able to put as many actors. If you take a look at the Piryx man game http://gamesalad.com/game/play/1488 we put in about 200 actor instances in the scene plus spawned actors. Although most of them are invisible actors for the buildings and intersections and have no behaviors.

    And so there is no confusion, objects in a scene are actor instances. The actors in the Actors tab of the Inspector are Actor Prototypes. Editing an actor prototype will change all the instances of that actor unless an actor instance has been edited to be different from the prototype.

    If you take a look at my Fill 2: Color Fill game, there is a toggle background button. That is just the scene's background color. No actor required except for the button. It looks and acts the same on the iPod Touch/iPhone.
  • beatragebeatrage Posts: 126Member
    CodeMonkey

    ok thanks for the hint!

    as I want to put background actors as fixed tiles with zero behaviors than I have no restriction!and if I want to change their color individualy I just need to edit each ones colors on the ones dropped on the scene, leaving the Prototypes.

    My character has a 20 sprite frames per animation( 20 per walk, 20per stand and 4 to punch) I think iphone an handle it what do you think?

    thanks for the replies CodeMonkey
  • madpoetmadpoet Posts: 59Member
    So if I have a bg file that's currently 960 x 320,
    I should change the file to 1024 x 512 and that will increase performance?

    Thx for the help!
  • BarkBarkCoBarkBarkCo Posts: 1,400Member
    I'n pretty sure a 960x320 image is stored in a 1024x 512 or 1024x1024 memory block. Increasing the size of your image won't help. This tip is more for people that have resources that are just outside a lower power of 2 and it wouldn't hurt to decrease their size a little to save memory.
  • madpoetmadpoet Posts: 59Member
    Thx barkbark

    So just to confirm,
    a 960 x 320 will be handled as if it were 1024 x 512.
    and a 257 x 256 would be handled like a 512 x 256
    In other words, it rounds out the dimensions to power of 2.
  • quantumsheepquantumsheep Posts: 8,188Member
    madpoet said:
    Thx barkbark

    So just to confirm,
    a 960 x 320 will be handled as if it were 1024 x 512.
    and a 257 x 256 would be handled like a 512 x 256
    In other words, it rounds out the dimensions to power of 2.

    Correct!

    And mega Zombie post :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: http://www.quantum-sheep.com

  • debugdesigndebugdesign Posts: 886Member
    interesting stuff... I have a game almost complete which uses five 640x1000px images as the background...

    So would these use the same amount of memory as if they were 1024 x 1024?

    Thanks
  • madpoetmadpoet Posts: 59Member
    No wonder my sea monsters were choking frame rates.
    Thx all!
  • quantumsheepquantumsheep Posts: 8,188Member
    debugdesign said:
    interesting stuff... I have a game almost complete which uses five 640x1000px images as the background...

    So would these use the same amount of memory as if they were 1024 x 1024?

    Thanks

    Yep - bang on!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: http://www.quantum-sheep.com

  • ORBZORBZ Posts: 1,303Member, PRO
    CodeMonkey, your link in your first post is broken.

    Some tips to optimization that i've also found helpful:

    Don't use constraints if you don't have to. use Change Attribute whenever possible, constraints fire constantly whereas change attribute fires only once.

    Limit your use of use timers, use self.time and game.time if you can.

    Image sizes, as CodeMonkey said.

    Minimize rules per actor, destroy actors that are no longer needed.

    Do with math what you would normally do with geometry overlaps, if you can.

    Turn off the Movable flag on actors that are not movable

    Turn off the visible flag for actors that are not visible.

    A few more... i forget :)
  • design219design219 Posts: 2,273Member
    ORBZ said:
    use self.time and game.time if you can.

    Self.time? I didn't know about that one. So if you want something to live for 2 seconds you can do something like... if self.time = 2, destroy actor?

    As for the broken link, this thread is over a year old. Some of the info has surely changed.
  • firemaplegamesfiremaplegames Posts: 3,206Member
    design219 said:
    Self.time? I didn't know about that one. So if you want something to live for 2 seconds you can do something like... if self.time = 2, destroy actor?

    yes, exactly.
  • EastboundEastbound Posts: 1,074Member, BASIC
    Each actor has a time attribute? Or were these created attributes that I missed somewhere?
This discussion has been closed.