September 21st, 2011

ALPACA Help Open Thread

Hi everyone, I’m going to leave this post up as an open thread for any questions, comments or issues you have using ALPACA. I can’t always answer questions immediately but I’ll do my best to respond promptly. Have at it!

113 comments to ALPACA Help Open Thread

  • Kate

    Thanks!!!! All works great now, I have made some actions with spokeDialog in Puzzle class and connected them to speechlines.js file – they are working perfectly. You were right about “still” animations. I didn’t put them to default frame.”Talk” frame of character, works as well :)

    The only thing that I have still problem with, is changing the playerScale or walkRate –
    I asked you about this under different tutorial, but maybe I will stick to this one, as it is the “main help centre” now. So I just want to change playerScale and walkRate on different bacgrounds.As you said, I changed in Engine, playerScale and walkRate from private to public static, and added to cases in newBackground function e.g Engine.playerScale=0.1; or Engine.playerScale=0.5; . I don’t get any compiler errors or output, but this is just not working (player doesn’t change its scale).
    I wonder if the problem is not with config data in Engine -> most of this stuff is
    set to private, and as “playerScale = configData.playerScale;”, maybe this makes it unable to change the playerScale from the Puzzle class level? But there is too many “config” information in Engine, so I don’t know which should be set to public then.

  • Kate

    Ok, I did something, and playerScale started to change! but it changes almost randomly, and not on this background, where is should be changed. I did the same experiment on sample project as well, and there is the same problem :(

  • Quinn

    @Kate – Can you post some code from your Puzzle class so I can see what might be going on?

  • Quinn

    @Kate – I see what the problem is with your playerScale; whenever a new background is created, it calls the newBackground method AFTER it’s already placed all the items and the characters, so it doesn’t use the playerScale value until the NEXT time it creates a background. Your character was being set to the scale for the room they just left, instead of the one where they just arrived. Here’s how to work around this: create a new method in the Puzzle class:

    public function setPlayerScale(thisBack:String):Number{
    switch (thisBack){
    case "mapa":
    return 0.1;
    break;
    case "room":
    return 0.4;
    break; // Repeat for the rest of the rooms
    default:
    return 1.0; // Or whatever the default is
    }
    }

    Now in the Engine class you’ll need to change the createBackground method. Around line 136 you’ll see the code
    player = new Player(stage, walkRate, targetBuffer);
    Right under this, before the code that sets the player’s scale, add a method call to the new method we just added in Puzzle, like so:
    if(toolbar) playerScale = puzzle.setPlayerScale(thisBack);
    (You have to check to see if the toolbar has been created yet, because the toolbar is what first creates an instance of the Puzzle class, more clumsy code on my part).
    That should fix your issue, I hope!

  • Kate

    I see it now, the problem was in changing backgrounds indeed.
    But your solution works! Now, it’s very easy to change playerScale in various backgrounds. Thanks a lot! :) )

  • Kate

    Ok…there is another little question (it seems I am becoming this 4 year old “one thousand questions in a minute” child)
    I use one object (A) on another (B) and there is an unconnected object C. After I use A on B, actionMC starts to play. Player and targetMC become invisible, but I also want object C to be invisible IN THE MOMENT the actionMC starts to play (I want to animate object C). That’s why I can’t use performedAction there. I tried to change PlayerAction file, but did not succeed :(

  • Quinn

    OK, here’s what I’d change. In playerAction, go to the playSimpleClip method, and add a line at the top:
    puzzle.prepareForAction(actionMC);
    Then create a new method in the Puzzle class:
    public function prepareForAction(actionMC:MovieClip):void{
    this.actionMC = actionMC;
    var clipString:String = String(actionMC);
    switch (clipString){
    case "THE_NAME_OF_YOUR_MOVIECLIP":
    // Now add the code to get the movieclip of item C, then make it invisible
    break;
    }
    }

    Hopefully, that should work!

  • Kate

    Hi Quinn, I don’t know why, but code doesn’t work, although it seems very logical, this is the part of my Puzzle: (PlayerAction is exactly like you wrote above)

    public function prepareForAction(actionMC:MovieClip):void{
    this.actionMC = actionMC;
    var clipString:String = String(actionMC);
    switch (clipString){
    case “[object action_HAMI_SEEDS]“: // I tried different names here like “ACTION_HAMI_SEEDS” etc. but it doesn’t work either.
    var szeryf;
    var baba;
    for (var i in Engine.usableItems){
    if (Engine.usableItems[i].displayName == “SZERYF”)
    szeryf = Engine.usableItems[i];
    if (Engine.usableItems[i].displayName == “BABA”)
    baba = Engine.usableItems[i];

    }
    szeryf.visible = false;
    baba.visible = true;

    break;
    }
    }

    Generally flash shows no errors, just “szeryf” and baba” don’t change

  • Quinn

    OK, try adding this code just below baba.visible = true;

    trace("Szeryf: " + szeryf, "Baba: " + baba);

    Then run the project and look at the output window. If you see “undefined” for either szeryf or baba, then the code is not finding the right movieclip. If you don’t see any output at all, then it’s not reading the movieclip as [object action_HAMI_SEEDS].
    In that case, try putting a trace statement at the very top of the method, saying something like:
    public function prepareForAction(actionMC:MovieClip):void{
    trace("prepareForAction called");

    If you still don’t see any output, then this method is not being called at all. Check all your names and make sure there aren’t any typos.

  • Kate

    Ok, I found the solution – so the problem was, that the function in PlayerAction I should place my reference to method into is NOT playSimpleClip(), but combineObjects() instead.
    From playSimpleClip method, flash didn’t see prepareForAction at all – I think that the problem is in playSimpleClip itself, does it actually work? With combineObjects() however, everything works perfectly!

  • Qoo

    Dear Quinn
    If player wish to restart the game without refresh browser
    how do I add the code in it
    I wish to add an additional button at the Option menu to do for it
    any suggestion?

  • David

    hello, it’s me david.

    how can i change the font? i change “Arial” to “Times New Roman” in subtitle.as, the text become empty in the game.

    thank you, Quinn.

  • David

    excuse me, i still have another question.

    {
    “option”:”This is my dialog option”,
    “response”:”This is the response”,
    “action”:”explosion”
    }

    Now open up Puzzle.as and add some code to the spokeDialog method:

    public function spokeDialog(thisDialog:Object):void{
    switch(thisDialog.action){
    case “explosion”:
    // Put whatever code you want in here to make something explode
    break;
    }
    }

    it was your past message, i want to know how can i remove the subtitle after “action”:”explostion”, because there is no “action”:”end”.

    thanks a lot :D

  • Quinn

    @Qoo – first you’ll need to make a method (probably in the Puzzle class) that resets all the puzzles to their original state and places the Player in the first room. Then you’ll need to add the new restart button to the options menu, and in the Options class, give it a mouse click event listener. I’d probably have it call a method within the Options class that puts up a little confirm box (“Are you sure you want to restart?”) just in case someone hits it by accident, and if the user confirms, just call the new restart method in the Puzzle class. You might need to tinker with the Engine class as well to get this to work (and could possibly put the startover method in there too – basically just have the class reproduce everything it already does to start the game). Hope that helps!

  • Quinn

    @David – You need to make sure your Flash project file is set to output the new font (check under Text->Font Embedding). That’s probably the issue.

  • Quinn

    @David – oops, good point! OK, instead of “action”:”explosion”, give it some other key name, like “specialeffect”:”explosion” or something. Then, in the spokeDialog method, run a switch statement on that instead.

    switch(thisDialog.specialeffect){
    case "explosion":
    // etc.

    Then you can just put in “action”:”end” like you normally would.

  • Qoo

    Dear Quinn
    This is the method I added in Puzzle class

    public function resets():void{
    allPuzzles = new Object;

    allPuzzles.room = new Object;
    allPuzzles.room.sphereUsed = false;
    allPuzzles.room.boxUsed = false;
    allPuzzles.room.gotBalloon = false;
    allPuzzles.room.switchOn = false;
    allPuzzles.room.usedSwitch = false;

    allPuzzles.hangar = new Object;
    allPuzzles.hangar.doorBroken = false;

    allPuzzles.tundra = new Object;
    allPuzzles.tundra.skyWeird = false;
    allPuzzles.tundra.skyWeirdCount = 0;

    allPuzzles.room = allPuzzles.room;
    allPuzzles.hangar= allPuzzles.hangar;
    allPuzzles.tundra = allPuzzles.tundra;

    var options = Engine.options;
    options.visible = false;

    Engine.newBack = “tundra”;
    stageRef.dispatchEvent(new Event(“changeBackground”));
    firstAction();
    }
    It works fine when changing the background.
    However, I can’t control the panda anymore.
    Moreover, the object in each background did not reset.
    for example, i had pick up the rock in tundra. After i restart the game, the rock still in my inventory.
    Any suggestion?

  • David

    tnank you, it’s works:D

  • Quinn

    @Qoo – hmm, maybe the Puzzle class is not the way to go; any step you miss (like not clearing out the inventory) will screw things up. I think the better thing to do would be to put the reset method in the Engine class. Have it remove everything – the Player, Inventory, Background, each and every object that was instantiated – and just call the startGame method again. That should start everything from scratch, which is what you want.

  • David

    Excuse me, I wanna load text with utf-8 in JSON.

    How should i do ?

  • Quinn

    @David – I think JSON strings are UTF-8 by default.

  • Qoo

    @David – I’m Taiwanese.
    Here’s my solution for using big5 text in ALPACA engine.
    Just embed the font in FLA file, something like ‘Microsoft JhengHei’ and it works.
    Hope that helps!

  • gwen

    Hi!
    First off Thank you for ALPACA! It’s exactly the sort of thing I was looking for for a college project I’m doing.

    However, I’m having a problem that I just can’t seem to solve. I have a character (Lemon) that I want the player to speak to. I converted him to a movieclip and gave him the instant name lemon_T. I’ve put in a usepoint. And, I wrote in some dialogue in the speechlines. But I when I test it, the usebox will show up, and the player will move to the usepoint spot, but then just freeze and I can’t click on anything or move.

    I’m getting these output errors:

    TypeError: Error #1010: A term is undefined and has no properties.
    at com.laserdragonuniversity.alpaca::Dialog/populateOptions()
    at com.laserdragonuniversity.alpaca::Dialog()
    at com.laserdragonuniversity.alpaca::UseBox/manipulateThing()
    at com.laserdragonuniversity.alpaca::UseBox/reachedThing()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at com.laserdragonuniversity.alpaca::Player/walk()

    This is a problem that seems related to the dialogue. It also prevents the player from examining anything else. If I comment out of the dialogue part from the speechlines, then I don’t have a problem and can look at the objects that can be examined. But, as soon as I uncomment the dialogue all the interactive items break.

    Am I just missing something?
    Thank you!

  • gwen

    Ah! Sorry me again. More error to add to that if it helps at all. My first batch came with my dialog still commented out. This shows up before Error #1010 when I don’t have dialog commented out:

    JSONParseError: Unexpected ]
    at com.adobe.serialization.json::JSONTokenizer/parseError()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder/parseArray()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder/parseObject()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder/parseArray()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder/parseObject()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder/parseObject()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder/parseObject()
    at com.adobe.serialization.json::JSONDecoder/parseValue()
    at com.adobe.serialization.json::JSONDecoder()
    at com.adobe.serialization.json::JSON$/decode()
    at com.laserdragonuniversity.alpaca::Engine/linesLoaded()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()

    If have the dialog uncommented then I get all that plus the Error I mentioned before.

  • Coppero

    Could someone please help? Please pretty please? I posted my problem under Part3 section of the tutorial. Basically I have 2 connected rooms, all works great till that point. The problem is: I can’t set the obstacle right.

    It seems I set the teleport and teleportProper wrong. I must click in the wrong order or something. I did it 10 times or more already, trying to follow the tutorial to the letter and I keep getting errors.

    Can someone please help me set up teleport and teleportProper in the right way? Refer to my post under

    Please help.

  • Quinn

    @gwen – It looks like you’re missing a comma or bracket or something somewhere in your JSON file (JSON is annoyingly strict that way). Try copying your entire speechlines file into this tool: jsonlint.org. It should tell you where the mistakes are.

  • Quinn

    @Coppero – answer posted in the Part 3 thread.

  • Coppero

    Thank you for your help regarding Part 3 thread problems. All fixed and works like a charm. :)

    Amazing work on the Alpaca tool. Man, you are a genius! I also watched your Flash movies on your personal website. My oh my… Incredible. It must have taken you and your friend ages to do all this! Looks awesome! Great voice acting btw. Amazing artwork. Not to mention it’s hilarious stuff. LMAO :)

    Anyway, I do have a kind of a general question. I changed the settings to 800 600 graphics size. I had to re-position the toolbar, but I found that rather quickly in Engine.as. I centered it as well. Yet I’d like to enlarge it, so it covers the whole screen length on the bottom. Couldn’t find that piece of coding. Where is it?

    Any reason why you made Alpaca smaller than 800 600? The animations seem more chunky, is that the reason? Can that be improved somehow with Flash?

  • Coppero

    Line 217 in Engine.as. I changed it to:

    private function createUI():void{

    toolbar = new Toolbar(stage);
    addChild(toolbar);
    toolbar.x = 50;
    toolbar.y = 550;

    inv = new Inventory(stage);
    addChild(inv);
    inv.x = 150;
    inv.y = 100;
    inv.visible = false;

    options = new Options(stage, musicURL);
    addChild(options);
    options.x = 150;
    options.y = 100;
    options.visible = false;

    saver = new SaveRestore(stage, saveURL, saveID);
    addChild(saver);
    saver.x = 150;
    saver.y = 100;
    saver.visible = false;

  • David

    Hello, Mr.Quinn. I have a new question.

    This is my test game: http://www.ntcu.edu.tw/adt097140/test.zip

    I want character walk on the ground, but if i click the obstacle, he will walk out of ground, go through the wall.

    thanks a lot, sir.

  • Coppero

    I asked 2 questions, but my post disappeared for whatever reason.

    1. Why don’t you want to make Alpaca 800 600 graphics resolution?
    2. If I change the resolution in general options, can you please indicate where is the part of the code, so I could make the options toolbar a bit bigger.

    Also, how can you make the walking animation a bit less “chunky”? There are options under Option in the toolbar, I know. But it still sort of suffers. Is there a way to make the animation more smooth and better looking in Flash?

  • Quinn

    @Coppero – thanks! As for the toolbar, it’s a movieclip contained in the Flash project library, so it might be easiest if you just edit it directly in Flash. I first made ALPACA kind of a while ago, when monitor resolutions tended to be smaller, so I think that was why I made it small and just never bothered to change it :)

    Your issue with the animation might be the fact that I’m using 15 fps as the base framerate for the project. I mostly did that because using a lower framerate can make the process of animating a bit quicker (at least for me) – if you bump it up to 30 fps, you’ll probably find that to be a lot smoother-looking.

  • Quinn

    @David – you’ll need to set up the wall as an obstacle and give it nodes like any other obstacle; otherwise there’s nothing stopping the player from walking directly through it. Check out the sample project for an example – the ledge in the tundra background uses this.

  • Coppero

    Thanks.
    Toolbar: found it in the Flash project library.
    Framerate: 30 fps is better. 50-60 fps seems to give a proper smoothness. Much better. But that brings another problem. With 50 fps the character simply walks too fast. How would you slow him down? I suspect a part of the code should be modified/adjusted?

  • Quinn

    @Coppero – change the walkRate value to something lower in the config file. The walkRate is the number of pixels the player moves per frame, so more frames will require a smaller distance.

  • Coppero

    Wow, much better! That pretty much turns the whole thing around. From a “choppy” performance to a very smooth one with the right speed. Looks good. Looks awesome!

    I was thinking… can I maybe show my flash project to you? You know, I could either email you the file or post it online somewhere. In this blog here I read that you were interested in what people do. Maybe you will have some comments, maybe you can point out something and maybe simply… you know, have fun with another silly flash application. :)

  • Quinn

    @Coppero – sure! I’m always happy to see what people do with the engine.

  • David

    Hello, Mr.Quinn.
    I’m sorry to bother you for a long time.

    This is a new question.
    http://www.ntcu.edu.tw/adt097140/test_talk.zip

    It’s my test project, the obstable can’t be talked.
    I do the same way as sample_project(the Door_T), but it’s not worked.

    I will updating my own game to thank you, when I figure this problem out!
    Thank you.

  • Quinn

    @David – out of town right now but I’ll replace this with a proper answer when I’m back :)

  • David

    When will you be back, thank you very much :)

  • David

    It works….the problem is finding out in speech.js, thank you for your jsonlint.org :)

  • Coppero

    I’ve got 2 problems with the engine:

    1. I placed an “obstacle” object on the bottom of the screen. It works ok, however there is a problem. Every time when the character goes in this area, it will first go to the node and then to the destination spot. Kinda “sig-zag” movements. Looks weired. Any way to overcome this problem?

    2. I placed a new Layer within Room1 and added some music (ambient music, which goes in a loop). Now when you leave the room, the music would still play. When you re-enter the room, the music plays again overlapping the old one, so you have it twice. How to set it right?

  • Coppero

    3. In your “sample_project” file, the one with the panda, you use various sound files: when examining objects or getting object. I can’t track down how you activate these sound files. Let’s say there is a file to examine the rock (“It’s a rock.” called ROCK_look) or a file to get a rock (“I got a rock. Woo hoo” called ROCK_get). Where do you actually bring thse files into stage? What Layer? Where?

  • Quinn

    @Coppero:

    1. I’d try moving your nodes around the obstacle until the movement looks more natural. There’s not a lot of science behind how the characters move when avoiding obstacles – it’s a bit hacky to tell you the truth :)

    2. I’d put some code in the Puzzle class to take care of ambient sound, rather than using the room movieclip in that way. The problem is that when you leave a room, the room is removed from the display list, but that doesn’t actually delete all traces of it – so you still have running audio, like in your case. By calling up the sound using code, you’ll have more control over when and how it plays.

    3. The audio files are called directly from the library, so you don’t need to put them on the stage. Check out the documentation for some explanation on how this works.

  • David

    Excuse me, where can I change font in the dialog option, not in Subtitle.as.
    Thank you, sir.

  • Martina

    Hi Quinn,
    I´m back and have a new strange problem.

    I have made a talkable Charakter and 9 Background. I can walk on all.

    My Problem now is, my useText box dosent show the Objekts any more… I dont know why because the only thing i have done, was make new Backgrounds, Exitarrows, StartPoints and one talkable Charakter.The usetextbox is on his place and i can click on it if i start the Game… But no Info… I dont know what i have done >.< do you have an Idea?

  • Martina

    the problem is gone, i have taken a older version from my game where the use Text is okey and have copyed my talkable Charakter and now its okey… i dont know whats the problem with the first file… but my Problem is gone ^-^

  • Quinn

    @David – I think you’ll have to change it directly in the dialog option movieclip in the library of your Flash project; should’ve put that in the code, but looks like I forgot :P

  • Quinn

    @Martina – glad that worked out! Comment again if you have the same issue again, I’m curious what the problem was.

  • David

    It works!!!!! Thank you Master Quinn!!

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>