A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 26

Thread: [RESOLVED] [HELP] Inventory problems

  1. #1
    Member
    Join Date
    May 2006
    Posts
    49

    [RESOLVED] [HELP] Inventory problems

    So my inventory is working quite well but when i drag an object from the inventory and out into the world it disapears. It's really gay cause i cant use my items on the world cause when i drag it out it disapears. So if anyone could help me id be very happy.
    Last edited by mylesb; 05-30-2006 at 12:35 AM. Reason: new title

  2. #2
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Could you be any more specific? Maybe a code snippet or an example swf?

  3. #3
    Member
    Join Date
    May 2006
    Posts
    49
    my code is fine. Its just i dont know how to make my items usable on the screen. eg In monkey island when u pick up and item, u can drag it on the screen and use it on sumthing. I want to know how to do that.

  4. #4
    Member
    Join Date
    May 2006
    Posts
    49

    [HELP] Guys cmon inventory problems

    Dudes ok, I'm at the last part of my engine if i can do one more thing its complete. The one thing i need is to be able to drag the item from the inventory, into the world. eg Monkey island. You pick up a stick, then a hook, u then combine them to make a stick with a hook on the end(i can do all this)then when it comes to getting the item and dragging it onto the world to use, it dont work. I dont know how to do it. If someone could help me sweet.

  5. #5
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    Mate, unless you post some code ( Like AD suggested ), or be a bit less vague on how you're doing things, no one's going to be able to help you, and bumping this thread won't change that

    You got the items in the inventory as movieclips yeah ? Tried a startDrag command on them to actually be able to drag them on to the main screen from the inventory ? If not look it up in Flash help, it's a really straight forward thing. So from there you're going to need to check were it's been dropped ( Do you just drop the item on to the screen, or on to the player sprite ? ), and once it's dropped check if it can actually be used in that situation.
    If it can, cool do your thing, if not, return it to the inventory.

    That's just really vague 'cause that's all I can give you towards it without more details.

    Squize.

  6. #6
    Member
    Join Date
    May 2006
    Posts
    49
    Dude can you tell me how to attach files, then ill put mine here so u can take a look at. it. Thanks.

  7. #7
    Senior Member
    Join Date
    Jan 2006
    Location
    USA
    Posts
    383
    Whenever click "Post Reply", just scroll down and click on "Manage Attachments" and upload the swf or fla or whatever it is you're wanting to upload.

  8. #8
    Member
    Join Date
    May 2006
    Posts
    49
    Ok, thanks man. ^_^.

  9. #9
    Member
    Join Date
    May 2006
    Posts
    49
    guys its 1 meg so can i send it to one of u guys emails.

  10. #10
    Member
    Join Date
    May 2006
    Posts
    49

    Plz Last Part Of Engine

    Hi guys. Ok i attached the file. Now i had digital real pics in the engine, but due to size i took them out and drew the backgrounds, as you will see in the engine. I am not concerned with graphics right now, I am concerned about the programming. I'm at the last part of my engine, 1 more thing and its complete. The one thing i need is to be able to drag the item from the inventory, into the world. eg Monkey island. You pick up a stick, then a hook, u then combine them to make a stick with a hook on the end(i can do all this)then when it comes to getting the item and dragging it onto the world to use, it dont work. I dont know how to do it. Now, I cant post the code because its not a matter of bad code, I just dont know how to do it alltogether. In recent posts u were asking for source code, asuming it was that that screwd it up. It wasnt, cause i dont know how to do it. I need one of u guys to give me the code to make it work. If you can do that, thankyou very much.

  11. #11
    Senior Member Gloo pot's Avatar
    Join Date
    Aug 2005
    Location
    Australia Mate!
    Posts
    874
    Im guesing its some sort of RPG or adventure game your making?, is it a side scroller or is it birds eye view / isometric.

    From what i can see this person want to know how to move an object out of his inventory onto an object in the actualy game (Not in the inventory) and trigger somthing to happed.

    Here is my example of what i think he means.
    The person is next to a fish pond, you open up your inventory and click and drag your finishing rod from your inventory to the fish pond, this triggers the player to fish.

    EDIT - You posted while i wrote this.
    Last edited by Gloo pot; 05-26-2006 at 01:10 AM.
    92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!

  12. #12
    Member
    Join Date
    May 2006
    Posts
    49
    YEP THATS!!!! IT MAN U HIT THE NAIL ON THE HEAD!!!!! Finally someone who understands me, thankyou so much GLOO!!!!!!!!!!!!!

  13. #13
    Member
    Join Date
    May 2006
    Posts
    49
    Now if i could have sum code that would do that for me id be grateful

  14. #14
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    "Now if i could have sum code that would do that for me id be grateful"

    lol.

    Here's a quote from me earlier...

    "Tried a startDrag command on them to actually be able to drag them on to the main screen from the inventory ?"

    Didn't type that for a laugh you know. You actually tried that ?

    Squize.

  15. #15
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    what you want to do is very complex. Each object you have can impact the world in a different way, so assuming that every object is different and can have a different action you need to set up functions specific to objects. If an interactive object exists it must have two values:

    1. what object it needs
    2. what happens when its activated

    so i'd add this to every event based object:
    code:

    //event based objects
    var myOb = "key";
    function myEvent(ob):Object {
    //check if the object is bad, if so break out of the function
    if (ob.type != myOb) {
    return {success:false, comment:"you cannot use this item here"};
    }
    //run the event, add whatever needs to be done here, like create a monster, open a door, or give an item
    giveGold(100000);
    //return a successful event
    return {success:true, comment:"you unlocked the door"};
    }


    and this to inventory objects
    code:

    //inventory objects
    //get original position
    var origX = _x;
    var origY = _y;
    var type = "key";
    //functions
    this.onPress = function() {
    startDrag(this);
    };
    this.onRelease = function() {
    stopDrag();
    //assumes that all event objects exist within a world movieclip named "world"
    //you can change this to whatever you want
    var world = _root.world;
    //check an event object
    checkOb = function (ob) {
    if (this.hitTest(ob)) {
    var eventData = ob.myEvent(this);
    _root.comment = eventData.comment;
    if (eventData.success) {
    removeItem(this);
    return;
    }
    }
    };
    //
    for (var i in world) {
    var ob = world[i];
    typeof ob == "movieclip" ? checkOb(ob) : null;
    }
    //we only reach this part if all checked objects we're bad
    _x = origX;
    _y = origY;
    };


    there's no defined way to do this, its just how i'd do it, it works like this:

    - your inventory item is dragged to the world
    - when the mouse is released check for all active objects
    - if the inventory object hits an active object, run the myEvent function on the object in the world
    - if the inventory object's type is right do the event, remove the item from inventory

    might not work because i can't read your mind and figure out how you've set up your game

    but hopefully it helps
    lather yourself up with soap - soap arcade

  16. #16
    Member
    Join Date
    May 2006
    Posts
    49
    mate thats great but i have done that already. I think the problem is that i have the items and inventory inside the same movie clip and if i try to drag the items out of the movie clip into the world it goes invisible. Sorry i didnt mention that before.

  17. #17
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,140
    Quote Originally Posted by mylesb
    mate thats great but i have done that already. I think the problem is that i have the items and inventory inside the same movie clip and if i try to drag the items out of the movie clip into the world it goes invisible. Sorry i didnt mention that before.
    why? do you have a mask on it

    its hard to help because i have no idea how you've set up your game.

    here's how i'd do it:
    code:

    function dragClip() {
    this.onEnterFrame = dragControl;
    this._parent._y = 400;
    }
    function releaseClip() {
    delete this.onEnterFrame;
    this._parent._y = 0;
    this._y = _ymouse;
    }
    function dragControl() {
    this._x = _xmouse;
    this._y = _ymouse;
    }
    clip.onPress = dragClip;
    clip.onRelease = releaseClip;


    that code exists within the inventory and works like this:

    - item (clip) is dragged
    - inventory is moved off stage
    - item's position is set to the inventorys _ymouse NOT THE _ROOT._YMOUSE very important.
    - when the mouse button is released, inventorys position is reset and clips position is set to the _ymouse again to prevent its position moving up.

    is that what you wanted?
    Last edited by mr_malee; 05-27-2006 at 11:21 PM.
    lather yourself up with soap - soap arcade

  18. #18
    Member
    Join Date
    May 2006
    Posts
    49
    dude can i have ur email? and ill send u my source code.

  19. #19
    Member
    Join Date
    May 2006
    Posts
    49
    nope it's all kool i figured it out. Ok now when i drag the item onto a hot point on the world how can i make it interact.

  20. #20
    Member
    Join Date
    May 2006
    Posts
    49
    Well guys I have finally done it, i have made the engine and am ready to announce the game that ICU Games is developing. This game will be entitled:
    WARNINGS FROM THE DEAD. Until the release plz visit our site to check on the games progress. I will be writing a developers log along with the rest of the team. The website is: http://www.geocities.com/icuproductions[U][B]. We are updating the site to a halfbreed of flash and browser, this will occur in the coming weeks. Thankyou.

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