mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-11-04 04:47:13 +08:00 
			
		
		
		
	Adding assertions
This commit is contained in:
		@ -22,15 +22,22 @@ class SpriteSheet {
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Sprite getSprite(int row, int column) => _sprites[row][column];
 | 
			
		||||
  Sprite getSprite(int row, int column) {
 | 
			
		||||
    final Sprite s = _sprites[row][column];
 | 
			
		||||
 | 
			
		||||
    assert(s != null, 'No sprite found for row $row and column $column');
 | 
			
		||||
 | 
			
		||||
    return s;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /// Creates an animation from this SpriteSheet
 | 
			
		||||
  ///
 | 
			
		||||
  /// An [from]  and a [to]  parameter can be specified to create an animation from a subset of the columns on the row
 | 
			
		||||
  Animation createAnimation(int row, { double stepTime, loop = true, int from = 0, int to }) {
 | 
			
		||||
    List<Sprite> spriteRow = _sprites[row];
 | 
			
		||||
    final spriteRow = _sprites[row];
 | 
			
		||||
 | 
			
		||||
    assert(spriteRow != null, 'There is no row for $row index');
 | 
			
		||||
 | 
			
		||||
    if (spriteRow != null) {
 | 
			
		||||
    to ??= spriteRow.length;
 | 
			
		||||
 | 
			
		||||
    final spriteList = spriteRow.sublist(from, to);
 | 
			
		||||
@ -41,8 +48,5 @@ class SpriteSheet {
 | 
			
		||||
        loop: loop,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
    return null;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user