I want to perform the following assignments. Build the sheetInfo file and file location string as classLoc and the newImageSheet file and file location string as imageFile using the incoming values className and pngName.
function \_M.spriteRun(spriteType, loops, runTime, x, y, seqName, className, pngName) print('run ',runTime,' ',x,' ',y,' ',seqName) local classCon = 'classes.' local classLoc = classCon..className local imageCon = '../Images/' local imageFile = imageCon..pngName print('spriteRun, classLoc: ',classLoc,' imageFile: ',imageFile) local sheetInfo = require( classLoc ) local imageSheet = graphics.newImageSheet( imageFile, sheetInfo:getSheet( ) ) local sequenceData = \_M.runSequence(spriteType, loops, runTime, seqName) local mySprite = display.newSprite( imageSheet, sequenceData ) -- -- execute called sprite -- print('name: ',seqName,' X: ',x,' Y: ',y) mySprite.isVisible = true mySprite:setSequence( seqName ) mySprite.x = x mySprite.y = y mySprite:play( ) end
Is this possible, if so what is the correct syntax for applying these two variables to the sheetInfo and imageSheet. Bot classLoc and imageFile are being successfully created. So either or both sheetInfo and imageSheet are nil as a result of this assignment.
spriteRun, classLoc: classes.Coins_Portals imageFile: …/Images/Coins_Portals.png
The error that is coming up is:
attempt to index local ‘mySprite’ (a nil value)