ENABLING BEHAVIOR

krazziebone02

  • Posts: 113
hi???is there a way to enable an actor behavior using button actor?? for example i have 2 scenes the name of the first scene was "1st scene" and the second was "2nd scene" so i want to do is in the 2nd scene there is a 1 button to enabled the behavior of the actor in the 1st scene

How will I do that?? do i need to use Custom Code??? or what is your suggestion

i hope you can help this is the problem on my THESIS
i want to be the best user of stencyl

MrWagoner

  • Posts: 424
It depends a bit on what the behavior does and what not, but one possible method would be:

1. Create a Game Attribute "ButtonClicked"
2. Create a "When Mouse pressed on"-Event in the Button-Actor
3. In the Event, set ButtonClicked = true
4. Attach the behavior you want to control (let's call it ExampleBehavior) to the other actor
5. In the "Created"-Event of the this actor, add code blocks like:

If not ButtonClicked
    Disable Behavior ExampleBehavior

By doing so, the behavior will only be enabled if the button in the other scene was pressed before.

Check out my newest game: Blowy Fish!

krazziebone02

  • Posts: 113
sir what attribute should i use??is it the color violet??? or the colr blue??
i want to be the best user of stencyl

krazziebone02

  • Posts: 113
sir what attribute should i use??is it the color violet??? or the colr blue??
i want to be the best user of stencyl

krazziebone02

  • Posts: 113
It depends a bit on what the behavior does and what not, but one possible method would be:

1. Create a Game Attribute "ButtonClicked"
2. Create a "When Mouse pressed on"-Event in the Button-Actor
3. In the Event, set ButtonClicked = true
4. Attach the behavior you want to control (let's call it ExampleBehavior) to the other actor
5. In the "Created"-Event of the this actor, add code blocks like:

If not ButtonClicked
    Disable Behavior ExampleBehavior

By doing so, the behavior will only be enabled if the button in the other scene was pressed before.


sir what attribute should i use??is it the color violet??? or the colr blue??
i want to be the best user of stencyl

MrWagoner

  • Posts: 424
Violet....these are the game attributes that will be carried over to the next scene, the blue ones will be "forgotten" when you switch scenes.

Check out my newest game: Blowy Fish!

krazziebone02

  • Posts: 113
Violet....these are the game attributes that will be carried over to the next scene, the blue ones will be "forgotten" when you switch scenes.

ok sir thank you very much
i want to be the best user of stencyl

krazziebone02

  • Posts: 113
Violet....these are the game attributes that will be carried over to the next scene, the blue ones will be "forgotten" when you switch scenes.

sir i have a problem on saving and loading a game

I have a scene (LEVEL MENU) and it includes level 1-25 so when i press level 1 it will proceed to the next scene that includes 1 picture and 4 buttons.....let us proceed to the level 1 I have a button in that scene includes the correct answer for the picture and i have a timer on that scene for rating a star so when the correct answer was  click between 30 seconds it will create 3 stars on the LEVEL MENU scene and the level 2 will unlock so the 3 stars was already draw in the LEVEL MENU scene  my problem is when i go to the level 2 and  press the correct button and i press the exit button to go back to the LEVEL MENU scene the 3 stars on my level 1 was gone why?? PLEASE HELP me sir
i want to be the best user of stencyl

MrWagoner

  • Posts: 424
It is hard to tell without seeing the code, but I can imagine two things:

1. Maybe you are using the same violet game attribute to store the star count for both levels, so when you solve level 2 it overwrites the contents of that attribute.

2. Depending on when you load / save your game, it could happen that the 3 stars for Level 1 were not saved yet, then you use the load game block inbetween which will load the value "0 Stars" for Level 1.

As I know now what you are planning to do, it should work if you are doing it like this:

1. Create a violet game attribute for every Level "Level1_Stars", "Level2_Stars", "Level3_Stars" and so on.
2. When you are in a level, put the rating in the corresponding game attribute. If we are in Level 2, put the value in "Level2_Stars" and so on.
3. Always Save after you have added a new Star value, Load only at the beginning of the game.

In this way it should work. If you don't want to create so many single game attributes, you can also use a list game attribute to store the values but these might need a bit more code blocks to handle them correctly.

Check out my newest game: Blowy Fish!

krazziebone

  • Posts: 1
It is hard to tell without seeing the code, but I can imagine two things:

1. Maybe you are using the same violet game attribute to store the star count for both levels, so when you solve level 2 it overwrites the contents of that attribute.

2. Depending on when you load / save your game, it could happen that the 3 stars for Level 1 were not saved yet, then you use the load game block inbetween which will load the value "0 Stars" for Level 1.

As I know now what you are planning to do, it should work if you are doing it like this:

1. Create a violet game attribute for every Level "Level1_Stars", "Level2_Stars", "Level3_Stars" and so on.
2. When you are in a level, put the rating in the corresponding game attribute. If we are in Level 2, put the value in "Level2_Stars" and so on.
3. Always Save after you have added a new Star value, Load only at the beginning of the game.

In this way it should work. If you don't want to create so many single game attributes, you can also use a list game attribute to store the values but these might need a bit more code blocks to handle them correctly.

sir should i use Violet attribute again??or the color blue oneS??


MrWagoner

  • Posts: 424
Ok, it starts to feel like I'm getting trolled here...why would you ask this question given all the context from our conversation and why would you do so from a different forum account?

Check out my newest game: Blowy Fish!