Limited moves per scene

ShivaFang

  • Posts: 248
Yup, you can either simply change the 'draw' statement to say
Code: [Select]
[Number of Moves allowed] - [Counter]instead of just [Counter].  This will still count up, but will display how many are left.


The other way would be to create a 'When Created' block and then;
Code: [Select]
[set Counter to [Number of Moves Allowed]]
Then in the block where you 'increment' counter, click on 'increment' and change it to 'decrement' (a pop up will appear on the block itself, you don't need to grab a new block.

This will basically set the counter to the total number of moves and then count down.  OH and you'll also want to change  'Counter>=MaxMoves' to 'Count<=0'  Almost forgot that important bit :)
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Okay thank you so much, the game is looking really good!! I have 2 questions left if you don't mind. Sorry for bothering you so much, anyway haha.

Question 1,
I made blocks that move back and forth and i wanted them to carry the smiley block with them instead of sliding out from underneath him. I changed the physics all around and nothing seems to work. Also they don't move back and forth where i want they stay on the same path all the time no matter where I place them is that in the behaviour?

Question 2,
I wanted to make a level select scene where you can click on the number and go to the level, but they are all locked until you beat them, so after you beat them they will unlock. Mainly so the players don't have to start a new game every time they want to play becuase eventually it will have a lot of levels.
Mitchell

ShivaFang

  • Posts: 248
I need to think about these a little more before I can come up with a way to do it, but just quickly off the top of my head;

#1  Check the forge - I think there's a 'platform' script there, but it might be just the actor with no code...

Roughly I would try to have them sense when they collide with a player and somehow check to make sure the player is still 'on' it.  Set a boolean "IsPlayerOnMe?" to true.  (Call it whatever you want.) 

I would then create an event 'every 0.1 seconds' on those platforms and then I would change the X and Y values of the player by the same amount as the x and y speed of the platform.  (because it seems to me that 'speed' is an increase per 0.1 seconds - I don't know if that's the actual definition the stencyl programmers use, just my observation.)

^ That is all off the top of my head.  No idea if that will work but experimenting and failing gives you ideas on what might be possible with a few tweaks.  Let me know how that turns out.


#2 is pretty easy.  Especially if they are in a straight 'sequence' (no branching paths).  You want a 'game variable' that you set in settings which indicates the highest level they have beaten.  Every time you beat a level you'd set this to the higher of it's current value or the number of the level (there's a block for that)

There's a default Library (when you click on 'attach behaviour' in an actor property and look under the library you'll see them) for a button to change the scene.  combine that with the '3 state button' that's also in there.  That code *should* have a 'disable' option.  You want the 3 state button to be 'disabled' if the level is lower than the level it is pointing to.


Try those ideas out - let me know if you have any problems.
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Ive only worked on the first question and i got them to move him, its a little glitchy and im trying to get them to move back and forth witch they do, but i want them to turn back when they hit a tile. Could you help with that? Also the second question I didn't really understand any of that sorry.
Mitchell

ShivaFang

  • Posts: 248
Okay.  Try changing 0.1 seconds to 0.02 seconds, but also divide the amount you move the actor by by 5.  This should smooth it out a little instead of being so choppy.

See what happens if you turn the boolean to FALSE after every time this happens (in the 'every x seconds' event).  I'm wondering if it 're-collides' and might produce the effect you are looking for.  (if it stops working when you do that, then remove it :D)



For #2
  1 - Go to 'settings' and create a 'Game Attribute' that is a number.  'Highest Level beaten'.  (Game attributes save when you use the same-game features, so this is why you want one of these instead of a Scene Attribute)
  2;
    2a - when you beat a level, use the 'Set Highest Level beaten to []' block in Attributes -> Game   
    2b - You want to use the block inside 'Numbers and Text -> Math'.  There's one there that says 'smaller of [] and []' drag that out.
    2c - Click on 'smaller' and a pop up will appear.  Change it to 'larger'
    2d - put 'Highest Level beaten' on one side and the current level on the other (you never want the player to lose progress if they play an old level, this makes sure they always get credit for the latest level :).
3 - create an actor.  For now, make this a simple square with different colours.  You can make it all fancy later.  You want the following animations;
  Normal - what the button looks like when it's on the screen (make this yellow)
  Pressed - what the button looks like when it's pressed (make this green)
  Hover - what the button looks like when it's pressed (make this blue)
  Disabled - what the button looks like when you have not yet beaten the right level (make this grey)
4)  Go to the 'Behaviours' button for the actor.  Click 'Add a Behaviour'.  Under 'FROM YOUR LIBRARY' select Game.  You should see one called 'Switch Scene Button' - you want that add it.
5)  Click 'Edit Behaviour on the top Right.
6)  You want to add 3 attributes to this behaviour;
    An Animation Type attribute named 'Disabled Animation'     NOT HIDDEN
    A 'Number' animation called 'Required Level'       NOT HIDDEN
    A 'Boolean' attribute called 'Disabled'       HIDDEN
7)  Go back to your actor behaviours and set the 4 animations to the right ones (if you only see 3 you did something wrong - maybe you hid the 'Disabled Animation' attribute or forgot to make it an animation).  Don't change anything else here - just the animations (for now)

... I think I have to do pictures for the next few steps - trying explain it  and draw it out would look a little confusing.  That should keep you busy for a bit anyways.


EDIT just followed my own instructions because I wanted to test it, so here's what the behaviour on the button you made should look like when you are done.

« Last Edit: August 14, 2012, 05:45:24 pm by ShivaFang »
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

ShivaFang

  • Posts: 248
Okay, now for the actual block/script changes.

Disable.png shows the changes you need to make to the 'Update' script for the 'Switch Scene Button'.  This should go right after the 'do only on iOS' block.

Then, in each of the four 'On Actor' buttons, that have an icon that looks like a mouse - you need to put that stuff in 'if not <disabled>' blocks.  This will prevent the mouse from affecting your button at ALL if it is disabled.

Once you have done all that.;
  1) Add a bunch of them to your level select screen (I used 4 for testing).  C
  2) Click on each one and go into the inspector. 
  3) Click customize.
  4)  Under the 'Switch Scene button' change the 'Level Required' and the 'Scene' for each one.
     4a)  The 'Level Required' should be '0' for level 1, '1' for level 2.. and so on.
     4b)  Your scene should be the right scene for each level ;)


Finally, a screenshot showing that is correctly disables them.


EDIT:  This is pretty solid, actually.  If it weren't for the fact that it uses a Game Attribute, this would be good for the Forge.


« Last Edit: August 14, 2012, 06:02:57 pm by ShivaFang »
Justin "ShivaFang" White
Aquamentos Games - The origin of challenging Strategy and Role-Playing Flash gaming!
Visit our Developer Blog and Google+ Page!

mitchewing23

  • Posts: 61
Oh my gosh!! you are amazing! It works perfectly :) thanks so much! I havent fixed the moving squares yet that carry the main character, but I will eventually. haha,,,
Mitchell

GreenGuy

  • Posts: 101
set the number to what ever you want it to be in the when created.
then subtract instead of add.
I am doing this to count down the number of times an actor can move :)
When it hits 0, the actor can not move anymore.
________________,.-*'Renewal'*-.,________________
http://community.stencyl.com/index.php/topic,10615.0.html
------------------------'*-.,Renewal,.-*'------------------------