The simple dress-up code, explained, and improved


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.

Advertisements
Explore posts in the same categories: ActionScript 2.0, Basic

Tags: , , , ,

You can comment below, or link to this permanent URL from your own site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: