|
-
Need dress-up game tutorial (click and snap type)
I have found how to do this in AS 3.0 with the drag and drop method (though not sure how to make that snap), but am looking for a button based one that clicks and then appears at desired location. I know it's simple, but alas, I don't know quite how to do it - anyone can point me in the direction of a tutorial (for AS 3.0)?
I understand it probably requires setting up movie clips with multiple frames, each containing (for example) a different top, then having a button with a function that swaps between the frames in that movie clip.
My guess goes something like this:
button.addEventListener(MouseEvent.onClick, switchIt);
function switchIt(event:MouseEvent):void
{
gotoAndStop( ... ???? ....)
}
Not sure how to say "go to the first frame of shirt_mc" (or second frame or whatever). Also, I'm starting out with no shirt on at all, so I assume there would have to be a command to actually display the mc to begin with, as well as a function connected to the "reset_btn" that clears all the movieclips from the screen when player wants to start over.
Off to continue researching, but if anyone has an answer that won't take much of your time or a link to a tutorial, it would be much appreciated.
Last edited by Leftyplayer; 08-17-2009 at 07:03 PM.
-
For "no shirt" just start with a clear keyframe in your movie clip. For the others, make a keyframe for each one and give it a frame label, then you can call those directly:
PHP Code:
function switchIt(event:MouseEvent):void{
shirt.gotoAndStop("coconutBikini");
}
Please use [php] or [code] tags, and mark your threads resolved 8)
-
Also - for snapping, detect where your item should snap to (ex 190,125) and when you drop an item, calculate if it's within 10px or so of that point:
PHP Code:
function dropShirt(e:MouseEvent):void{
shirt.stopDrag();
if(Math.abs(190 - shirt.x) < 10){
// within 10px left or right
if(Math.abs(125 - shirt.y) < 10){
// also within 10px above or below
shirt.x = 190;
shirt.y = 125;
} else {
// not close enough vertically - reset
shirt.x = 0;
shirt.y = 0;
}
} else {
// not close enough horizontally - reset
shirt.x = 0;
shirt.y = 0;
}
}
Please use [php] or [code] tags, and mark your threads resolved 8)
-
You mean something like this?
Code:
on (press) {
startDrag(this, true);
}
on (release) {
stopDrag();
if (this._droptarget == "/sprite_mc") {
_root.sprite_mc.gotoAndStop(2);
}
}
On your sprite, have all the frames on stop.
Make frame 2 the item you want on the sprite.
--------------
First make a movie clip called dragger.
Then in the movie clip, draw an item and make it a button.
Add the code above to the button. And give the button the instance name drag.
-----
Sources: My game.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|