So, II found out the problem The:
The functions in python return NoneNone by default
So, so when the while loop turned falseFalse it returned NoneNone thus throwing an error.
import pygame
import json
pygame.init()
c=0
def lcAnim(sfile):
global c
with open(sfile) as f:
data=json.load(f)
width=data['textureAtlas']['regionWidth']
height = data['textureAtlas']['regionHeight']
img=pygame.image.load(data['textureAtlas']['texture'])
if c>=len(data['cycles']['animation0']['frames']):
c=0
if c<len(data['cycles']['animation0']['frames']):
img.set_clip(pygame.Rect(data['cycles']['animation0']['frames'][c-1]*width,animpos*height,width,height)) # Locate the sprite you want
draw_me = img.subsurface(img.get_clip()) # Extract the sprite you want
c+=1
return draw_me
```