Hi All,
I haven’t used Lua before now and have a quick question with regards to arrays of objects.
I have some arrays which look like this:
g.group[i][1] = Text
g.group[i][2] = Text
g.group[i][3] = Animation
g.group[i][4] = Image
g.group[i][5] = Text
The animation is essentially a loading animation that’s displayed while information is still being downloaded, however, the user can still click around while the info is being downloaded.
The problem is when I want the animation to be unloaded if I use display.remove or removeSelf it then readjusts the array making g.group[i][4] = g.group[i][3] (and 5 equal to 4), which then breaks my references to those elements in other code.
Is there are correct way to unload the animation from memory without removing the array entry entirely. I’ve tried setting it to nil but that errors. I can set it to a static image (which is what I want to do anyway), but I don’t think it’s then correctly unloading the animation. At the moment I’m just setting it to isVisible = false, loading an image in it’s place and carrying on. That works fine, but I’m assuming that is going to cause a pretty major memory leak over time.
Any help would be appreciated.
One other quick question too, I’ve found it easier to load specific things whether the app is loaded on iPhone or iPhone 4 as I don’t like the scaling features, however, this means that code below fails as I cannot declare the variables as local within an if statement, whats the best way to handle this?:
if display.contentWidth == 320 then
local imgArrow = display.newImage(“rightarrow_iphone.png”, true)
else
local imgArrow = display.newImage(“rightarrow.png”, true)
end
Cheers,
- Will [import]uid: 61273 topic_id: 10641 reply_id: 310641[/import]
