Posted tagged ‘dress-up’

The simple dress-up code, explained, and improved

August 3, 2008

So, you’ve surely heard about dress-up games. Many of them are of low quality, but there’s still some good ones, that I could make a list of, but let’s focus on this tutorial.

It’s really simple to make a dress-up game, one of the reasons many choose to let their first game be a dress-up game. Sadly, they don’t put much of effort into those games, which is the reason dress-up games have a bad reputation.

STEP 1:

Let’s have a look at the classic dress-up game code. It’s really simple, and I’m now gonna explain it.

on(press){//when this MC gets clicked
startDrag("");//This starts the dragging
}
on(release){//when you release the mouse
stopDrag();//This stops the dragging
}

Now, that’s simple. And not a good code either. One of the flaws is the on(release){
code part. It’s bad, because sometimes, your cursor maybe won’t be above the MC. Especially if it’s animated, but also if it’s a small object (still not recommended to use small objects, even if I’m gonna show you a better code). The code have now been improved a little bit:

on(press){//when this MC gets clicked
startDrag("");//This starts the dragging
}
onClipEvent(mouseUp){//when you release the mouse, no difference if the cursor is above the MC or not.
stopDrag();//This stops the dragging
}

So, that’s a small fix, which still is a good fix.

STEP 2:

Now, this is a fun thing we did to the code. we modified what thing gets dragged. Remove your script from your current MC and give it the instance “thing”. Now, make another MC, which will have the following simple code:

on(press){//when this MC gets clicked
startDrag(_root.thing);//This starts the dragging, at the MC with the instance name "thing"
}
onClipEvent(mouseUp){//when you release the mouse, regardless the cursor is above the MC or not.
stopDrag();//This stops the dragging
}

Yeah, that was it, soon, I will post some a bit more advanced tutorials.