How to change scenes at hidden object end
Seth

Hello Clockwork Chilli! I am new to the forum and to html5. I have started to make a hidden object game, I have a menu.wsc page that loads on start. After that you click on a start button and it clears the menu and takes you to scene1.wsc which is my first scene in my hidden objects game. So... Here is my question (I've watched all the videos and searched the forum, to no avail) Once the user has found all the objects, I would like to say something like GOOD JOB! and then advance to scene2.wsc. How would I go about doing this? Do I edit the hiddenobject.js file? Thank you in advance for any advise you can provide!

All 4 Comments
Seth

UPDATE - 

 

OK, so I tried this:

Posted 07 May 2015 - 09:51 AM

Hi and welcome to the forums

 

Firstly, it's a nice idea for a game, I like the timing element. There are several ways of doing that, and which one is best depends on what you want to do with your game (like, will that be the only level, or will there be more levels? etc).

 

You could do this (I'm assuming you're using the editor):

 

  1. For every "hidden object" in the scene, add a property to it, to mark it as an object that the player has to find (see the picture below, I'm setting a flag called "objectToFind").

    hogprop1.png

    hogprop2.png
     
  2. In hiddenObject.js, at the bottom of the onMoveComplete function (after removing the object), add this code to look for any objects that have that flag. If there are no more objects with that flag in the scene, the game is over:
    if (!wade.getSceneObjects('objectToFind', true).length)
    {
        // game is over, do something here
        wade.clearScene();
        wade.loadScene('gameOver.wsc'); // you'll need to create a game over scene
    }

    I hope this helps, let us know how you get on.

And it worked perfectly for me! However, I'm trying to display 2 sprites after if (!wade.getSceneObjects('objectToFind', true).length) instead of going to GameOver.wsc.

now I have the sprites in the scene already, they are just not visible yet. How can I make them visible at the end here? Also, am I doing this wrong? Because one of my sprites will have an onMouseDown event to go to the next scene (and even though it is not visible, I think you could still accidently click on it).

 

UPDATE 2

 

I tried putting this in:

{

    // game is over, do something here
    wade.setSpriteVisible('greatjob', true);
    wade.setSpriteVisible('nextbutton', true);
}
    };
Didn't work.
Gio

Hi Seth

 

To show your objects:

wade.getSceneObject('myObjectName').setVisible(true);

And if the sprite / object is not visible it won't receive any input events such as onMouseDown.

Seth

Thanks Gio, everything works like a charm! You guys are really helpful around here. I can't wait to share my work with you guys when I'm done! Happy Holidays!

Seth

UPDATE:

 

Ok, so now I'm working on the second scene. I made a new scene2.wsc file, made another hidden object scene, and then I merged a few objects from scene1.wsc (a backbutton, that works fine, and I also merged greatjob and nextbutton). Now on scene1 these 2 objects are hidden until everything is found, but on scene2 the first object that is clicked, these 2 objects show right away instead of waiting until the end. Do you know what I am doing wrong? Should I not merge these 2 objects? Thanks again!

 

UPDATE:

 

My bad, I just forgot to add objectToFind:true to my objects in scene2. It only took me 4 hours to figure that out, lol.

Post a reply
Add Attachment
Submit Reply
Login to Reply