A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Inventory items with number collected for each item?

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    19

    Inventory items with number collected for each item?

    Hi when collecting items in the as2 game I been working on I want an x number of what I collected of each item. If I pick up say the same item two times instead of slot1 and slot2 having the same item filling them, I want slot1 to have x2 next to the item and slot2 to still be free until a different item comes along in the game.

    I have know idea how to do this? And can't find anything on this subject.


    What I used for the pick up of the item.

    PHP Code:
    onClipEvent(load){
        
    touched false;
        
    }

    onClipEvent(enterFrame){
        if (
    this.hitTest(_root.tiles.char) and touched == false){
            
    touched true;
            
    this._visible false;
            
            
    _global.new_item "potion";
            
    _root.slots();
            
    _root.game.Tile16 _root.game.Tile0
            
    if(_root.tiles.char.hitTest(this)){
            
    _root.score+=5;
            
    // this.removeMovieClip();
             // this.gotoAndStop(2);
            
    unloadMovie(this);
            }
            
            
            
        }


  2. #2
    Junior Member
    Join Date
    Jul 2013
    Posts
    19
    Ok I worked out how to get the items to only add one of each different item with amount of that item but I'm having problems here, when text reads 0 in the _root.potion variable
    I want that slot to gotoAndStop at none labeled frame.

    PHP Code:
    on(release){
        
    _root.potion -=1
        
    if (_root.potion =0){
            
    _root.inventoryboxed.inventory.slot2.gotoAndStop("none");
        }

    If anyone knows why this aren't working much appreciated.

  3. #3
    Junior Member
    Join Date
    Jul 2008
    Posts
    23
    It looks like your problem is with the "=" operator. Using one equals sign is for setting a value; to compare two values, use the "==" operator.

    For example:
    Code:
    ...
    if (_root.potion == 0){
    ...
    Quote Originally Posted by hokayli View Post
    Ok I worked out how to get the items to only add one of each different item with amount of that item but I'm having problems here, when text reads 0 in the _root.potion variable
    I want that slot to gotoAndStop at none labeled frame.

    PHP Code:
    on(release){
        
    _root.potion -=1
        
    if (_root.potion =0){
            
    _root.inventoryboxed.inventory.slot2.gotoAndStop("none");
        }

    If anyone knows why this aren't working much appreciated.

  4. #4
    Junior Member
    Join Date
    Jul 2013
    Posts
    19
    Thanks so much for your help I really appreciate it! This solved the problem and it all works great.

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