Set Background on iOs ?

LePoulpe

  • Posts: 181
Hello

I'm looking for the equivalent of this on iOS :

Code: [Select]
setScrollSpeedForBackground (x, y);to adjust the speed of Background in Flash.

Code: [Select]
setBackground ("Background1", "Background2");for changing the Bakground in Flash.

I found here : http://community.stencyl.com/index.php/topic,3466.msg73040.html#msg73040
to change the background, that you had to use this on iOs:
Code: [Select]
[[Game game] setBackground:25];But this does not work for me.

Anyone know the 2 equivalents for iOs ?

Thanks

h1rnz1lla

  • *
  • Posts: 649
the set background does work, at least for me. did you typed in the right id of your background image?

LePoulpe

  • Posts: 181
Thanks h1rnz1lla for your reply

It works for me, but the background appears behind the current background (I don't see it) and it really drags down framerate.
Do I need other manipulation for changing the Bakground ? (cf screenshot)

And on the adjustment of the speed of Background, anyone know it the equivalent for iOs, that would help me ?

Thanks



« Last Edit: August 09, 2012, 01:40:54 am by LePoulpe »

h1rnz1lla

  • *
  • Posts: 649
mhh strange. as rhys wrote on the other original thread "The iOS version removes all backgrounds and adds the one background that you specify. However, it only accepts background IDs, not background names."

this is how it works in my code. when im back at my computer i will check my code for you.

LePoulpe

  • Posts: 181

h1rnz1lla have you had time to check your code ?
I checked, I use the good background ID  not background name.
It's really weird like you said, this is supposed to remove all backgrounds and add a new one...


And for the equivalent on iOs to :
Code: [Select]
setScrollSpeedForBackground (x, y);Nobody has a solution on this ?


It's really important to set the background especially in scrolling games on iOs, at present we cannot change anything on iOs during the game.

Thanks for your help

bonzero

  • Posts: 488
I use actors for the parallex background effect, and i'm getting a good performance.

Each actor (background) has a speed directly related with the main character's speed, something like (negate((characters speed)/4)) something like that.
Those actors are anchored to the screen, and once they are out of the screen they go back to the origin point.

How do I repeat the background while it's moving, to cover the blank spaces? I use the drawimage option, to copy itself to the right or left depending to where the main character is moving.

The drawimage option is great to repeat backgrounds since it takes far less memory than putting 1,2 or 3 actors more.

and the effect is pretty cool, I will post a video of the game im working in.

bonzero

  • Posts: 488
im using a 960px (480px 1x) image for the background this way each parallex background only needs to mirror itself once (using draw image), "prota" is how i'm calling the main character. As you can see it's just a few lines of code and the performance quite good even with 3, 4 layers of parallex


LePoulpe

  • Posts: 181
Wow, Thanks Bonzero
I adapted it to the vertical scrolling and It works perfectly !
I tried to handle this through the creation of repeated Actor but the result was not convincing, I never thought achieve this with the Draw image block.

But unfortunately it do against all other Drawing blocks disappear from the Scene (rectangle,circle...).

bonzero

  • Posts: 488
mm I think you have to make sure that everytime you use the drawing block it has a "move pen to" indicating where the object you want to draw should be drawn, always before the "draw line or whatever", I have noticed that if you don't indicate that, the drawing rectangles, lines etc could be  being drawn somewhere else outside the screen

In this game, I don't have problems using those parallex actors + a few drawn objects doing that.

LePoulpe

  • Posts: 181
Indeed it was the solution !
All the drawing block work well with move pen to before.

You seem very experienced in the workings of Stencyl.
Thank you very much for your help and for sharing your experience with the  Stencyl community.

bonzero

  • Posts: 488
Thanks, lots of trial and error and testing on the device  8)
Im glad to be able to help people using stencil, it's an amazing tool but there's still some workarounds that need to be done when developing for iOS