mattcolman / phaser-list-view

List view class for Phaser. Great for high scoreboards.
http://mattcolman.com/labs/phaser-list-view/index.html
MIT License
114 stars 22 forks source link

Cant create more the one `listView` #32

Open verybluebot opened 4 years ago

verybluebot commented 4 years ago

Failing in creating more then one listView

one is running over the other even though im assigning the instances to different vars and even using different parents on listView constructor

    this.right = {};
    this.left = {};

    renderScroller (x, y, items, obj) {
        const bounds = new Phaser.Rectangle(
            x,
            y,
            500,
            600
        );

        const options = {
            direction: 'y',
            overflow: 100,
            padding: 50
        };

        obj = new ListView(this.game, this, bounds, options);

        obj.scroller.enable();

        obj.addMultiple(...items);

        obj.tweenToItem(0, 2);
    };

   const items = [
           this.game.add.image(0, 0, 'image-name'),
           this.game.add.image(0, 0, 'image-name')
     ];

    // Then calling the above render twice 
   this.renderScroller(100, 500, items, this.left);
   this.renderScroller(500, 500, items, this.right);

// 'this' is a class extending Phase.Group that contains this snippet 

any solution/ walk around??

Thanks

verybluebot commented 4 years ago

Ok My bad, I was trying to use same images array as items for both list.. this messed things up apparently..

once I created a new item list for each ListView I was abled to render 2 instances.

Maybe this will help someone in the future, wasted a ridicules amount time on this :/