Random frame on start of layout?

0 favourites
  • 6 posts
From the Asset Store
three fully animated characters ideal for your RPG side scroller projects
  • Before going to the stage, I have added a layout where I give some tips for the game.

    So, I have added a sprite having 10 different frames, I want to show a random frame each time player open the Stage 1.

    So what I did this!

    It may sound lame but please guide me.

  • No, you need to use "Set frame" action. Set frame to random(Sprite.AnimationFrameCount)

    Also, don't forget to set animation speed to 0 in animation editor.

  • Thank you so much :)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • dop2000

    Could you PLEASE PLEASE help me to crack this.

    construct.net/en/forum/construct-3/general-discussion-7/help-global-variable-group-146355

    I got a solution from brunopalermo but he kind of provided some different and advanced way to doing this and I really appreciated his input but what I want here is simple global variable to store. Everything else is working fine with but the only issue continues button it loads everything expects the difficulty mode.

    Please help me pal.

  • brunopalermo is right, if you simply need to set different values for two variables, event groups is a huge overkill.

    If you don't like his solution, just create one variable Difficulty and a function SetDifficulty:

    Function SetDifficulty
    	if Difficulty=1 : set life=50, lifeMax=50
    	else if Difficulty=2 : set life=100, lifeMax=100
    	else if Difficulty=3 : set life=200, lifeMax=200
    

    When player chooses game difficulty, set the variable, write it to local storage and call this function.

    On start of layout read this variable from local storage and call the function:

    On start of layout
    	Local storage get "difficulty"
    	System wait for previous action
    	set Difficulty=max(1, LocalStorage.ItemValue)
    	Call SetDifficulty()
    
  • brunopalermo is right, if you simply need to set different values for two variables, event groups is a huge overkill.

    If you don't like his solution, just create one variable Difficulty and a function SetDifficulty:

    > Function SetDifficulty
    	if Difficulty=1 : set life=50, lifeMax=50
    	else if Difficulty=2 : set life=100, lifeMax=100
    	else if Difficulty=3 : set life=200, lifeMax=200
    

    When player chooses game difficulty, set the variable, write it to local storage and call this function.

    On start of layout read this variable from local storage and call the function:

    > On start of layout
    	Local storage get "difficulty"
    	System wait for previous action
    	set Difficulty=max(1, LocalStorage.ItemValue)
    	Call SetDifficulty()
    

    Thanks, dop2000

    I finally make it work with continue button by putting "On Load Complete" then compare difficulty level global variable and it worked.

    What I am doing is quite lengthy, I will defiantly adopt what you and brunopalermo suggesting me to do in future. As always Thank you very much.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)