Reset Button/Link sprites
ambiggs

Hello.

I've created a hidden object game that's pretty basic - you click on the sprite and a circle appears around the object. 

What I want to do is threefold:

1 - when they click on the found object, it automatically crosses the item found off a list that is next to the image.

2 - I would like the game to have a reset button for when they want to start over.

3. I would like the game to congratulate them when they find all the sprites.

 

Can someone please help!?

Comments 1 to 15 (16 total)
Gio

Hi

In short:

1. There are many ways to do it, but personally I would make the list so it contains several SceneObjects, one for each of the hidden objects that you have to find. These SceneObjects in the list should contain two sprites: one TextSprite with the name of the item, one normal Sprite with a line (to cross things off the list). Each line sprite should be set to be invisible (visible = false), and the Sprite name should be line.

Then you need a way to "link" your hidden objects to the corrensponding entry in the list. You could do this by using a naming convention, so if your hidden objects are called catdog, banana, etc. then your objects in the list could be called list_catlist_doglist_banana.

If you do that, and you are using a behavior for your hidden objects, in the behavior's onClick or onMouseDown function:

_['list_' + this.owner.getName()].getSprite('line').setVisible(true);

2. Just add a SceneObject for your button, and in its onMouseDown function:

wade.loadScript('myScene.wsc', null, null, true);

Where myScene.wsc should be replaced with the current file name.

3. Keep track of how many objects there are and how many have been found. You can create an event in the scene's timeline (in the Scene Properties in the editor) at time 0, and you can use it to initialize a variable like this:

wade.app.numObjectsToFind = 10;
wade.app.numObjectsFound = 0;

Then in your hidden object behavior's onMouseDown function:

if (++wade.app.numObjectsFound == wade.app.numObjectsToFind) {
    wade.loadScene('congrats.wsc');
}

Where congrats.wsc is a scene files with whatever you want to show to congratulate the player.

I hope this helps, good luck :)

ambiggs

Sweet! I will certainly try this! I'll post a link to the current game as soon as I get approval. 

ambiggs

Nevermind. lol 

ambiggs

Ok...I'm not sure what I'm doing wrong... for the congrats.wsc, i just added an image that should switch out. No code or anying. 

Also, the reset button does not work... my scene is named scene1.wsc adn that's what I put...but it keeps acting if the sprite is not there. 

 

Gio

Hi

Looking at that screenshot, I think there is simply a typo: you have called your file congrtats.wsc (there's an extra t), and are trying to load congrats.wsc

ambiggs

Well, lol! Who knew! Thank you! 

ambiggs

Hi.

I'm still working on linking sprites. Here's my trouble:

I have an image where the list of items already noted. All the sprites are loaded into the image, where when you run the game, you click on the image indicated in the list, and a circle will appear around it. 

What I'm trying to do is to, when that circle appears around the item, a line appears across the pre-printed list that is on the image. 

I tried the code provided, but I couldn't get it to work. 

Can you give me some advice?

 

Ashley

Gio

Can you show me the code that you're using to display the circles?

ambiggs

On Mouse Down for each sprite, this is the code:

this.getSprite(0).setVisible(true);
if (++wade.app.numObjectsFound == wade.app.numObjectsToFind) {
    wade.loadScene('congrats.wsc');
}


 

ambiggs

Here is the link to the finished game - hopefully that will give you an idea what I was trying to do. LOL

 

https://www.marylandlibraries.org/Pages/Day-by-Day-March.aspx

Gio

Hi

That looks nice, I like the graphics :)

I think if you're doing it this way, the best option would be to add an extra sprite to your scene objects. This sprite should be a line, that you can position in the right place over the list for each sprite by setting the sprite offset in the editor. It should be initially invisible, and i would call it "line". Note that this is the Sprite's name, not the SceneObject's name.

Once you have done that, just add this line to your onMouseDown functions:

this.getSprite('line').setVisible(true);

This would be easier if it was all done with behaviors (you wouldn't have to duplicate your code in that case), but seeing  as you've already got it working this way, I believe this would be the easiest solution.

ambiggs

Thanks. It's a statewide literacy campaign. 

Sorry, I'm a bit confused.

I tried as you suggested, and it made the 3rd sprite bigger but didn't allow me to move it anywhere. In fact, making any edits to the two sprites I already have on the scene object, by adding a third and trying to move it just moves the entire scene object. 

When adding this code, even with adjusting the offset, the line does not appear. 

ambiggs

Would it be possible to do this as a scene object instead? 

this.getSceneObject('line1').setVisible(true);

However, I do this and I get a TypeError that SceneObject is not a function. 

If I try to do it by adding the line as a SceneObject with Sprite Name line1, it gets the error message that it cannot read property.

 

Gio

You can do it either way.

1. Adding a sprite, and then moving it by changing its offset (not by moving the SceneObject):

OR

2. Creating a separate SceneObject, however the correct syntax is 

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

or better (less typing, but it's exactly the same):

_.line1.setVisible(true);

 

ambiggs

OMG - that last one worked! Amazingly well. 

THank you so much!

 

Post a reply
Add Attachment
Submit Reply
Login to Reply