Sprite error
- 
					
					
					
					
 Hey, 
 I am trying to put stuff on the screen and it is giving me "Invalid variable access."My code is for i = 0 to len( rocks ) loop If anyone knows what the error is, please tell me! 
- 
					
					
					
					
 We're going to need to see far more than that! there's nothing wrong with that line alone. Unless it IS alone and there's no more :D 
- 
					
					
					
					
 for I = 0 to len( rocks ) loop n = random( 4 ) rocks[i].spr = createSprite() setSpriteImage( rocks[i].spr, rockImgs[n] ) rocks[i].pos = { screen.x + random( screen.x * 2 ), random( screen.y ) } rocks[i].vel = { random( -screen.x / 5 ), random( 32 ) - 16 } setSpriteAnimation( rocks[i].spr, 0, 39, 10 ) setSpriteLocation( rocks[i].spr, rocks[i].pos ) Repeat
- 
					
					
					
					
 This post is deleted!
- 
					
					
					
					
 Some things that might be worth checking: - is rocksImgsindeed an array containing 3 images?
- Is the variable screenindeed a struct with the propertiesxandy?
- what does the rocksarray contain before going into this loop? Do the structs in therocksarray already have the propertiesspr,posandvel?
 
- is 
- 
					
					
					
					
 From the code snippet that's published above there are loads of variables being used that don't exist. So without further info, I would indeed expect to see an invalid variable access error. But I guess you have other code that you're not showing us. 
- 
					
					
					
					
 It is working for me but I had to assume the variable/struct definitions were something like this: struct rock var spr int pos int vel endstruct rock rocks[10]
- 
					
					
					
					
 BTW you don't need to create your own position and velocity properties as sprites already have them! 
- 
					
					
					
					
 Is rocks a struct, or is it meant to just be an array of sprites? If it's the latter changing rocks[i].spr to just rocks[i] would probably fix it. 
- 
					
					
					
					
 But we're all just guessing.... 
- 
					
					
					
					
 I found out why it was giving me an error. I misspelled a word in the code and I forgot a "," 
 
			
		 
			
		 
			
		