Author Topic: I cannot remember these SPRITE/OBJECT numbers...  (Read 2919 times)

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
Hi,

there's folks who cannot remember the indices of their sprites/sounds. Or the numbering requires an insertion of a new resource (for aesthetical reasons). For all these I sketched a method of using names instead of numbers:

Code: GLBasic [Select]
    spr_human = DynLoadSprite("Human.bmp")

    SPRITE spr_human, 0,0
    SHOWSCREEN
    MOUSEWAIT


FUNCTION DynLoadSprite: file$
    LOADSPRITE file$, GLOBAL spr_id_max
    spr_id_max = spr_id_max + 1
    RETURN spr_id_max-1
ENDFUNCTION


FUNCTION DynLoadSound: file$, buffer
    LOADSOUND file$, GLOBAL spr_id_max, buffer
    snd_id_max = snd_id_max + 1
    RETURN snd_id_max-1
ENDFUNCTION


FUNCTION DynLoadObject: file$
    X_LOADOBJ file$, GLOBAL obj_id_max
    obj_id_max = obj_id_max + 1
    RETURN obj_id_max-1
ENDFUNCTION
it's obvious what I mean, isn't it? All these functions should go in C:\Program Files\GLBasic\Projects\Common\DynLoad.gbas and can be inserted in any project from there easily.

Regards,
Gernot

Hb!

  • Guest
I cannot remember these SPRITE/OBJECT numbers...
« Reply #1 on: 2007-Sep-18 »
tsk i cant believe it even i... a donkey..... im able to use that and they arent able to remember number codes? is that soo hard? tsk XD

Offline Kitty Hello

  • code monkey
  • Administrator
  • Prof. Inline
  • *******
  • Posts: 10715
  • here on my island the sea says 'hello'
    • View Profile
    • http://www.glbasic.com
I cannot remember these SPRITE/OBJECT numbers...
« Reply #2 on: 2007-Sep-18 »
The problem sometimes arises, when you have the animations from 0-15 full, and now need to insert a sprite right in between. Then the aproach above is better.
I, however, prefer the numbers myself, too.