Hi all,
just begin to use picotron and it's really great.
I'm trying some picotron features (fortunately it is very similar to pico 8 so it is easy to use the basic commands) but I don't know how to use graphics that are not in the 0.gfx file (I have tried fetch("gfx/1.gfx")) but it doesn't seem to work). Does anyone know how to do it?
Thank you very much in advance
fetch is a command to load data into a variable, it does not affect the currently loaded cart
one thing we know (from the new manual):
> Each .gfx file contains up to 256 sprites, and if the filename starts with a number, it can be indexed by the map editor
but no mention of a function (or memory location to copy to) to change which spritesheet is «active» so that spr refers to it
Thanks, Merwok!
Reading again "starts with a number"... Due that each file can store upto 256 sprite images, Ive tried add 256 to the sprite number and it works... So spr(257,100,100) draws the second image of 1.gfx.
I've tried with 3 files and it works. Only add 256 for each file and you can access it.
Maybe Zep releases a function for it, but meanwhile it's working and let us use several gfx files at same time.
Best regards.
@merwok I think you either have to pass the sprite as first argument to spr or use set_spr
to bind a sprite to an index rather than set an entire sprite sheet globally.
@braindead You can actually use fetch
for a less fragile solution, here's what I did in my code:
Sonic = { ... sheet = fetch("./gfx/sonic.gfx"), ... } function Sonic:draw() spr( self.sheet[self.animation.sprite].bmp, self.x + self.sprite_ox - camera_x, self.y + self.sprite_oy - camera_y, self.sprite_flip ) end |
You just have to return the bmp
field of an individual sprite, which I believe is just userdata.
Hi, @TeamPuzel!
Thank you, your method is better than mine! I'll use it.
Best regards
Thanks for answering, you made my day. I also want to know it.
Hi, @TeamPuzel,
After fetching a .gfx sheet for an object: 'sheet = fetch("./gfx/sonic.gfx")', will the system load a new instance of the sheet for every instance of the object? Like if I created 5 Sonics will the system handle 5 of those same sheets at a time? So what I'm asking is if it's loading the sheet into RAM or creating a pointer to a memory address.
Thanks!
[Please log in to post a comment]