Thursday, 08 January 2009
 
  Home arrow Forum  
Main Menu
Home
News
Forum
Documentation
Download
Links
Administrator
Login Form
Welcome, Guest. Please login or register.
January 08, 2009, 02:24:22 PM
Username: Password:
Login with username, password and session length

Forgot your password?
Freeing Sprites
DSLua Community
Welcome, Guest. Please login or register.
January 08, 2009, 02:24:22 PM
1724 Posts in 316 Topics by 10301 Members
Latest Member: blendybeite
DSLua Community  |  DSLua - Best scripting language for Nintendo DS  |  Examples/Tutorials  |  Freeing Sprites « previous next »
Pages: [1]
Author Topic: Freeing Sprites  (Read 1216 times)
sylus101
Waxing Crescent
**
Posts: 74



« on: October 18, 2007, 09:23:26 PM »

Early on, I remembered reading that you had to set a sprite frame to 0 before freeing it. This held very true, as not doing it causes numerous glitches.

I also found that trying to initially create a sprite on some frame other than 0 didn't want to work right and you seemed to have to set the frame immediately afterwards as freeing a sprite that was created on a frame other than 0 would again cause glitches.

What seems to work, without a great amount of testing but my initial results have been good, is that instead of always setting a sprite back to frame 0, you just need to set it back to the frame it was created on!

I created a sprite at frame 8 and set it to frame 8 before freeing and so far, no glitches to be seen. This was in DSLua 0.6... haven't tried in 0.7 yet...
« Last Edit: October 18, 2007, 09:26:14 PM by sylus101 » Logged
sylus101
Waxing Crescent
**
Posts: 74



« Reply #1 on: October 25, 2007, 01:45:24 PM »

Forgive the double post, but to further the idea, here's a way you might utilize this (as I've done more testing and it works very well...) without having to remember what the frame was a sprite was created on. It'll eat up memory with one more variable, but hey... what's one more in the grand scheme of things?

Before creating your sprite, set your variable to the frame you're about to use.
Code:
spritecreateframe = 3
sprite = Sprite.Create(spriteframe,spritecreateframe,0,100,100)

When that sprite needs to be freed, just set the frame back to where it was created beforehand, without going through your script to find what frame it was created on:
Code:
sprite:SetFrame(spriteframe,spritecreateframe)
sprite:Free()
Logged
Pages: [1]
« previous next »
    Jump to:  



    (C) 2009 DSLua

    DSLua - Best scripting language for Nintendo DS home-brew!