Behaviour for changing background

Sunny

  • Posts: 53
Hey is there a behaviour or something to change the background when button is touched?

Thanks
Sunny

Rob

  • *
  • Posts: 1268
Not sure about this. But in the extreme case, you can make a large background actor with 2 animations so that one can change from animation 1 to 2 upon button press.

You can also request for help in the Ask a question subforum since there are more people there who can offer help. istencyl is only limited to istencyl tester + some other testers.

« Last Edit: September 10, 2011, 12:37:01 am by Rob »
GOLDEN RULE #1 : SAVE YOUR GAMES FREQUENTLY
IOS/XCODE DEBUGGING
http://www.stencyl.com/help/view/xcode-ios-troubleshoot/
WATCH STENCYLWORKS VIDEO TUTORIAL BY SUNRISEKINGDOM
http://www.youtube.com/watch?v=KDfRfjzr9j4&feature=channel_video_title


Rhys

  • Posts: 1046
This is pretty confusing to implement multiplatform, as it behaves differently for flash and iOS.


The flash code requires the name of the original background on the left, and the new background on the right.
The iOS version removes all backgrounds and adds the one background that you specify. However, it only accepts background IDs, not background names.

To find your background's ID go into the Stencylworks folder, then games, then your game name. Open up the resources folder and find your background.

The ID is the image's number. For this background, I would use:
[[Game game] setBackground:25];
But for flash, if I were switching from a background called "Night" I would use:
setBackground("Night", "background");

malospam

  • *
  • Posts: 467
What platform? I've done a full menu where you can press on certain areas of the image and it takes you to a specific level. Put a region where you want the user to be able to touch or click. I then have an invisible actor that is always at the x,y position that the user presses. My code then goes, if actor is in the region, switch to stage ___. I think that's the easiest way. hope that helps.
Visit Reddit's Stencyl page and contribute to spread the word about this amazing program!
http://www.reddit.com/r/stencyl

Sunny

  • Posts: 53
thanks guys
will try it out!

malospam

  • *
  • Posts: 467
Rhys, I was having that same issue with the collision problem that I posted, and which Jon moved to another subforum. Same code, yet flash returns the name you have given it, which I think is the most logical, but iOS returns very detailed information such as "Actor: Actorname actornumber". The problem is, if you don't know what a function that behaves like this returns, you will have alot of problem.
Visit Reddit's Stencyl page and contribute to spread the word about this amazing program!
http://www.reddit.com/r/stencyl

Rhys

  • Posts: 1046
??? That doesn't have anything to do with backgrounds.

nev

  • *
  • Posts: 384
Quote
This is pretty confusing to implement multiplatform, as it behaves differently for flash and iOS.


The flash code requires the name of the original background on the left, and the new background on the right.
The iOS version removes all backgrounds and adds the one background that you specify. However, it only accepts background IDs, not background names.

To find your background's ID go into the Stencylworks folder, then games, then your game name. Open up the resources folder and find your background.

The ID is the image's number. For this background, I would use:
[[Game game] setBackground:25];
But for flash, if I were switching from a background called "Night" I would use:
setBackground("Night", "background");

Is there the possibility that this will be implemented in a block (no code line)?

Nev

Jon

  • *
  • Posts: 17524
We'd need to clean up the support across both platforms and come up with a more formal set of procedures to support.

jaystansfield

  • Posts: 53
This is pretty confusing to implement multiplatform, as it behaves differently for flash and iOS.


The flash code requires the name of the original background on the left, and the new background on the right.
The iOS version removes all backgrounds and adds the one background that you specify. However, it only accepts background IDs, not background names.

But for flash, if I were switching from a background called "Night" I would use:
setBackground("Night", "background");

This has been a fantastic help for me over the last couple of days but i ran into a problem. I wanted to have 4 separate backgrounds that changed according to the number of a game attribute...this code didn't allow for that as when the background is changed you're left with the new background. setBackground("background1", "background2");

Where background2 is now set as the background I didn't know how to turn that into background3 and then back to background1.

Attachment shows that i finally figured it out- hope this helps people!

LePoulpe

  • Posts: 181
Hi

For me it works in Flash but not on iOs.
I have added the code to set the background and I check the background's ID into the Stencylworks folder but it doesn't matter.

Does anyone have an explanation for that ? I don't understand where is the problem.

Thanks


« Last Edit: July 12, 2012, 07:15:11 am by LePoulpe »

GiantOakStudios

  • *
  • Posts: 136
Does this still work in the latest version of stencyl 3 ?
I am making a flash game and I cant seem to get it to work.
My line of code is identical AFAIK and I have double and triple checked the BG names.

kierannolan

  • Posts: 64
I'm making a desktop game with changing backgrounds, I ended up using a screen sized actor and switching between animations for it based on an attribute value.

 I did try the code from this thread, I'm not sure whether it's an error on my part or if the feature is not implemented in the current beta version.

Bhoopalan

  • Posts: 1018
In case someone is still trying to figure out how to use this, I would say use 'hide layer with name' block.

You can add two backgrounds. The default background should be on the first layer. The second background should be below this layer. When a button is pressed, you can hide the default background so that the next background appears.

I tried this and works. I just hope this would help someone else ;)
If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan