A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Hooking a duck style action

  1. #1
    Member
    Join Date
    Oct 2009
    Posts
    31

    Hooking a duck style action

    Hi.

    I'm trying to make a game in Flash CS4 for my final year uni project.

    As part of the project i am learning Flash from scratch.

    I've been through a couple of books and have a basic idea of what I'm doing.

    My game is for kids, basically its based in the sea, along the bottom of the screen are randomly generated letters which flow past in some moving water, above that are fish swimming past with words on them, these words have letters missing, the user controls a hook with their mouse and the idea is to hook a correct letter from the bottom of the screen and feed it to the fish to complete the word.

    I have so far got the mouse control working, and am able to hook up a letter but by a very simple hitTest and if its hit then add the letter to the hook as a child.

    Ideally I want it to realise there is a hit and animate the letter falling onto the hook so it hangs from the bottom of it. Does that make sense?

    Does anyone know of any tutorials for games like hooking a duck (fairgorund style) as this would probably be useful. Or any tips from yourself?


    Another thing I should ask while I'm posting is if there are word libraries around, as this is a word game I'm going to need a library of words that the game can randomly shoose from, and then to check whether the letter they have fed the fish creates a real word or not.

    Thanks for any help.

    Mike

  2. #2
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    Yo Mike,

    Are you using AS2 or AS3?

    A quick solution I thought of, might not necessarily be the easiest, is to use a Tween library to Tween the letter to the hook.

    1. Click the letter.
    2. Tween letter to the hook.
    3. When tween completes, remove the letter. And go to a frame on the hook movieclip with a letter attached.

    You can use tweenMax. http://blog.greensock.com/tweenmax/

    This is an AS3 example, AS2 shouldn't be too much different...

    PHP Code:
    // import library
    import com.greensock.*;

    // start tween, have this fire when you click the letter
    var time:Number 3// time in seconds
    var tempLetter:MovieClip myLetter// you can set the letter you clicked to a temp variable that you can use to target it. Think of it as a shortcut or reference
    TweenMaxmyLettertime, { x:myHook.xy:myHook.yonComplete:letterTweenComplete});

    // this function will fire when the tween completes
    function letterTweenComplete() {
    removeChild(tempLetter);
    myHook.gotoAndStoptempLetter.value ); // gotoandstop on frame "a" or whatever

    For this I'm assuming that each letter movieclip has a "value" variable in it with the letter it represents. So for the G you have:

    PHP Code:
    myG.value "g"
    I hope this makes sense, haha.

  3. #3
    Flash Intermediate XenElement's Avatar
    Join Date
    Sep 2008
    Location
    At my computer
    Posts
    196
    I think theoretically, you could make this very simple.

    The Hook Drops, and there is a hitTest fired to see if you catch the letter.

    Now, lets assume we have the letter in a generic holder.

    If your hook hits the letter in the same place no matter what letter it is, then you could animate the holder to do XYZ when the hitTest fires.

    This way, you could set the holder to always do XYZ when the hitTest happens, ie: moving onto the hook.

    Then, once you have the holder MC, you can just add the letters to duplicates of the holder and it will move to the hook in the same set way every time.

    ----You only want the above if you want to make the movements----

    Otherwise, you can search for tutorials on the Tween AS3 class, which allows you to tween a movie clip for its current spot, to say, where ever the hook is.

    As for word dictionaries, I believe there was a thread way back about those...

    ah here we go:
    Dictionary Thread

    A word dictionary is what you should use to get all of your words.

    Cheers, hope I helped, at least a bit!
    In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.

    ---

    Check out my blog at XenElement.com

  4. #4
    Member
    Join Date
    Oct 2009
    Posts
    31
    Cheers for your reponses, I think I get what your ideas and will give them a go tommorow.

    I think I've got quite a task to do this in 3months with currently not a lot of as3 knowledge!

  5. #5
    Flash Intermediate XenElement's Avatar
    Join Date
    Sep 2008
    Location
    At my computer
    Posts
    196
    Ah. Well that should be plenty of time, and you're learning in the best way. If you have something that you can immediately apply new knowledge to, it'll stick better. Also, keep asking for help here on the boards, it is often faster to resolve problems here even if it takes a long time to explain your problem.

    Cheers m8!
    In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.

    ---

    Check out my blog at XenElement.com

  6. #6
    ism BlinkOk's Avatar
    Join Date
    Aug 2001
    Location
    , location, location
    Posts
    5,002
    don't get all bogged down by the physics or logic of hooking a letter. you are not making a simulation of the real world, you are making a game.
    just have all the letters in one fame and then an image of them when they are hooked in the next frame. when the hook hits the letter switch to the hooked image.
    Graphics Attract, Motion Engages, Gameplay Addicts
    XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro

  7. #7
    Flash Intermediate XenElement's Avatar
    Join Date
    Sep 2008
    Location
    At my computer
    Posts
    196
    Actually, he has a good point.

    It's a game. You don't have to make it exactly right, you don't need any sort of physics on this. however, I was making the assumption that you had letters floating around upside down, and in that case, you would use the AS tweening to flip the letters into the right position.

    But, as usual, BlinkOk is right. It's a game, and a children's game at that. If you want, you could even just make a puff of smoke and have the letter appear on the hook, already rotated, and set in the right spot, etc.



    [EDIT] @ BlinkOk:
    I got the impression that the hook is what contained the letter, making it much easier to move up toward the word with minimal code, etc. So I guess your very nice example would be reversed, or something. Dunno.
    In the process of designing a quirky little game engine called gulp. Check out it's progress below: @ my blog.

    ---

    Check out my blog at XenElement.com

  8. #8
    Member
    Join Date
    Oct 2009
    Posts
    31
    What I've done is have a small tween which shows the letter slide down onto the hook play when there is a collision.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center