Skip to content

Publish a list of sprites #27

Open
@Kababaer

Description

@Kababaer

Hi,

I cannot seem to get it to run.
I have a list of sprites which I want to be displayed vertical and the user should be able to scroll through vertically.

var startX = this.fHeader.x;
	var startY = this.fHeader.y + this.fHeader.height;

	var sprites = [];
	this.highscores.forEach(function(highscore) {
		var sprite = game.add.sprite(startX, startY, 'spriteKey');
		startY += sprite.height;
		sprites.push(sprite);
	}, this);

	var bounds = new Phaser.Rectangle(0, 0, 1000, 2000);
	var options = {
		direction : 'y',
		overflow : 100,
		padding : 10
	};

	var listView = new PhaserListView.ListView(game, this, bounds, options);

	var newItem = game.add.group(this);
	listView.addMultiple(sprites);
	newItem.nominalHeight = 120;

	listView.add(newItem);

This is actually taken from the example, but the line
listView.addMultiple(sprites);

causes issues: updateTransform of children[i] is not a function. When I add the sprites directly to the group "newItem", then I won't get any error, but therefore I see nothing (I mean, the listview nowhere).

So I ask myself, how to actually do it?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions