PDA

View Full Version : stick



rahul_7star
May 31st, 2008, 02:11 AM
Hi see this game
http://www.tallhat.com/matches/

Now what they have used to check the ans is they had store the x(say x=200)and y(say y= 300) value of solutions to a variable and whenever it matches you win , the problem is that if you drag all these stick to some other places(then x and y values changes), and then chk you wont be havng right ans , now i want to have other logic to do this ... any help


HI guys , i got stuck with the ans checking logic to this type of game......help me ....

rahul_7star
June 2nd, 2008, 07:52 AM
HI
i am having 8*8 grid and i am having a move clip, whenevr you release that movie clip it should attached itself to its nearby Grid(8*8)......any help

neilmmm
June 2nd, 2008, 01:17 PM
try


var g_gridSpacing:Number = 40;
_mc.onRelease = _mc.onReleaseOutside=function () {
this.stopDrag();
// Stop Dragging
X = this._x;
// Reference X Pos
Y = this._y;
// Reference Y Pos
if (X<320 && Y<320) {
this._x = Math.round(X/g_gridSpacing)*g_gridSpacing;
// Round to nearest GridSpace
this._y = Math.round(Y/g_gridSpacing)*g_gridSpacing;
// Round to nearest GridSpace
}
};

rahul_7star
June 3rd, 2008, 03:35 AM
Thanks but i want something like this ....see the fla..



try


var g_gridSpacing:Number = 40;
_mc.onRelease = _mc.onReleaseOutside=function () {
this.stopDrag();
// Stop Dragging
X = this._x;
// Reference X Pos
Y = this._y;
// Reference Y Pos
if (X<320 && Y<320) {
this._x = Math.round(X/g_gridSpacing)*g_gridSpacing;
// Round to nearest GridSpace
this._y = Math.round(Y/g_gridSpacing)*g_gridSpacing;
// Round to nearest GridSpace
}
};

neilmmm
June 3rd, 2008, 11:31 AM
you need to use hitTest

draw a copy of your grid

make each mtach stick position an mc and put a reference to each stick position in an array

then alpha copy grid to 0

when moving a matchstick, on release just do a hitTest to array of alpha out matchsticks in a for loop

the sticks do not have to snap to _x and _y but if you want them to they can match the _x and _y of the match with alpha O

this will also easily give you a match to see if the game is finished

hope this helps

rahul_7star
June 3rd, 2008, 11:47 AM
you need to use hitTest

draw a copy of your grid

make each mtach stick position an mc and put a reference to each stick position in an array

then alpha copy grid to 0

when moving a matchstick, on release just do a hitTest to array of alpha out matchsticks in a for loop

the sticks do not have to snap to _x and _y but if you want them to they can match the _x and _y of the match with alpha O

this will also easily give you a match to see if the game is finished

hope this helps


well if you can post a fla then i can have some idea..........right now i am not able to make it