Forums

ForumsProgramming Forum

Anyone Wanna Help me improve my code?

Posted Feb 24, '13 at 8:06pm

cheese123

cheese123

20 posts

So I am a newb at flash and you guys seem reasonably nice (compared to some other places)

So I was wandering if you were willing to help. I appreciate the help of anyone but to the experienced programmers - please don't laugh if my code looks stupid.

Anyway thanks for reading.

 

Posted Feb 25, '13 at 6:06am

strouthas

strouthas

24 posts

Any specific question?

 

Posted Feb 25, '13 at 9:55am

cheese123

cheese123

20 posts

Yea I do have one.

In a point and click game what is the best way to speak to characters? I have thought about adding another frame in the character and a bunch of movie clip buttons but I don't really like this idea.

Then maybe just a uniform dialogue movie clip (a blank square) that attaches to the scene when you click a character and fills up with dialogue. Then it unloads once you are done. This method seems like it could get messy when coding. I was thinking maybe an array to store dialogues of the different characters, another array to store the unique button labels (like hello) for each character. But maybe its over complicated?

I think the first method is just better because it's the simple solution, but something tells me that both these ideas are bad.

 

Posted Feb 25, '13 at 9:57am

cheese123

cheese123

20 posts

I don't like the first idea because imagine all the movie clips you'll need. It seems like a waste.

 

Posted Feb 25, '13 at 11:39am

boppins

boppins

500 posts

Administrator

Kind of hard to get a picture of what you need -- got any screenshots?

A point and click game could be a few things.  Is it a static screen with things to click on like Myst?  Or is it more like Monkey Island where you click and your character moves?

I think both solutions sound okay.  Do what is easy and easy to maintain (and doesn't hurt performance).

 

Posted Feb 25, '13 at 11:48am

weirdlike

weirdlike

475 posts

Knight

You can't improve on nothing.... also coding is very tedious you can try doing this

Remember 1 frame 1 action layer as noted here

Insert a new layer labeled dialogue. Create the talking bubble or square, create 2 if you have another person talking.

Then click on the keyframe and highlight it, modify>convert to symbol.

Converting the keyframe to a symbol (and don't forget to name the instance) instead of the object itself makes it a separate video to play within the main (root) timeline.

At this point you can control the conversation

function mouseClick1(event:MouseEvent):void
{
    trace("Mouse clicked mouseClick1");
        dialogueBox.gotoAndStop(1);
}
....
dialogueBox.gotoAndStop(2);
dialogueBox.gotoAndStop(3);
....

Then you can keep control of the conversation by adding an additional layer on the newly created symbol and giving a label name like "hello" and "bye"
...
dialogueBox.gotoAndStop("hello");
dialogueBox.gotoAndStop("bye");
...

there may be a better way to do this but this one works for me

DEMO

fla

links above will break at any time...

 

Posted Feb 25, '13 at 12:08pm

weirdlike

weirdlike

475 posts

Knight

sorry if my previous post seems too aggressive no offense intended, it was actually longer and I edited it to make less reading

 

Posted Feb 25, '13 at 12:21pm

strouthas

strouthas

24 posts

What I prefer most, is a class injecting a semi transparent frame on top of the display list, holding the text you want. You can have properties about the alpha amount, the font to be used, the window size of the frame etc. Now, whenever you need the dialogue displayed you just call the show method of the class, passing the resource id (if you have all the dialogs in an XML) or the text itself.

 

Posted Feb 25, '13 at 1:53pm

cheese123

cheese123

20 posts

@ boppins - just a black box on the screen with the same 3 dialogue buttons (which change labels depending on who you click)
@weirdlike - that seems closer to my first solution
@strouthas - i know nothing about classes 

- thanks!

 

Posted Feb 25, '13 at 2:40pm

weirdlike

weirdlike

475 posts

Knight

have you tried this, I used arial as the font

var format:TextFormat = new TextFormat();
var myFont:Font = new Arial ();
format.font = myFont.fontName;
message_txt.defaultTextFormat = format;     
message_txt.text = "You awake from sleeping...";

message_txt.addEventListener(MouseEvent.CLICK, mouseClick);

function mouseClick(event:MouseEvent):void
{
    trace("Mouse clicked");
    message_txt.text = "you feel sick";
    message_txt.removeEventListener(MouseEvent.CLICK, mouseClick);
    message_txt.addEventListener(MouseEvent.CLICK, cont);
    function cont(event:MouseEvent):void
    {
        trace("Mouse clicked2");
        message_txt.text = "perhaps too much to drink...";
        message_txt.removeEventListener(MouseEvent.CLICK, cont);
    }
}

same demo link as above click refresh page
new fla example here

 
Reply to Anyone Wanna Help me improve my code?

You must be logged in to post a reply!