View Full Version : help with game creation
I have this script on a button, what happens is the user drags a little square into a bigger square and then the little square disappers, and it works. What I need help on is now I want to have them be able to drag other little squares onto the bigger square and the bigger square not change (its a game), but I cant figure out the script.
on (press) {
startDrag (this, true);
}
on (release) {
stopDrag ();
if (this._droptarget == "/almostredbox") {
_root._lightgreensquarebutton._visible = 0;
_root.almostredbox._visible = 0;
_root.almostdkredbox._visible = 1;
_root.mandy=_root.mandy+1
}
Jesse
02-01-2001, 06:47 AM
So you have like 5 boxes which you want to drop onto another box and each time you want the smaller one to dissapear? ( Or does the smaller on dissapear only the first time?)
That shouldn't be too hard. You'll need to use relative paths as much as possible to cut down on the scripting.
But first let's address this:
_root._lightgreensquarebutton._visible = 0;
If that code is right you have an element with an underscore as it's first character. I wouldnt' advise that.
Now, this code will make the button you place it on dissapear when it's dropped on the bigger box...
on (press) {
startDrag (this, true);
}
on (release) {
stopDrag ();
if (this._droptarget == "/almostredbox") {
this._visible = 0;
_root.mandy=_root.mandy+1
}
Hope this helps.
Cheers
Jesse
I am trying to do a similar game in which little squares are dragged in a bigger square. The little squares must be moved into a specific location in the big square because the little squares make up a picture when arranged in the proper order. I need help scripting and I want to make the scene advance to the next phase only if the little squares are all arranged
Jesse
02-17-2001, 06:47 AM
By your other post (in tutorial requests) I assume you were talking about one of those slider puzzles. Are you trying to create puzzle where you drag and drop pieces into their positions or one of those slider puzzles where the piece are all jumbled up and you click one piece to slide it horizontally or vertically (these are a lot harder)?
Gimme more info and I'll help out
Cheers
Jesse
I'm trying to do one of the puzzles where to image boxes are all jumbled up when the page is loaded. The user just has to drag them back into place. Its not the slider puzzle because the pieces can just be dragged over each other. Artnomad.com is a design group that has a puzzle like it on their site under their portfolio section within the flash work tab
TAHNKYOU for helping
Jesse
02-19-2001, 05:58 AM
OK, in my experience the best way to make such things is as follows:
Your puzzle is divided roughly into a grid.
|_|_|_|
|_|_|_|
|_|_|_|
Let's say like that, for a 3 x 3 puzzle.
You create an MC whjich has a square, about the size of one grid segment, and then lay out copies of this MC on the stage, alpha faded to 0% (invisble). So you now have 9 copies of this MC on the stage and you should give them instance names in the form of [row,column]. So the top left one would be "11" and the bottom right one would be "33".
Then you break your puzzle down into the same number of piece and make each piece a draggable button (button within an MC). Then you give your MCs instance names corresponding to that of their targets, so the piece of the puzzle which goes in the top lef tcould be called 'piece11' and the piece for the loer right, 'piece33'.
Then, you can use drag and drop and _droptarget checks to see if the piece has been droppe on the right square.
Something like:
on (press) {
startDrag (this, true);
}
on (release) {
stopDrag ();
if (this._droptarget == (substring ( _name, 1, 5 ))) {
// piece has been dropped int he right place
} else {
// piece has NOT been dropped int he right place
}
}
So this takes the name of the square where the user dropped the piece and checks if it corresponds to the number of the piece. If it does, you can add one tot he count of piece correct or something, and if it doesn't the best idea it to move the piece back to where it came from so the user is clear that they've made a mistake.
You may also want to centre pieces if they are correct. I can show you how to do these last two things if you can't figure them out yourself, but for now, have a fiddle and see if this method is for you.
Cheers
Jesse
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.