DRAWANIM on iOS

Previous topic - Next topic

Darmakwolf

So I did some research on DRAWANIM on iOS. Looks like you need square textures no bigger than 1024x1024 to be safe - which is perfectly fine with me except for the problem I'm having. I have an array of TYPES. When a room is loaded in my game, the map file tells the program how many enemies are in the room. The program then DIMPUSHes enemy data from an enemy database file. One element in the TYPE is a GENSPRITE() variable, like so:

TYPE mob
x
y
a
f
eID$
sprite
ENDTYPE

and as I push a new mob into the array, I set the "sprite" element to GENSPRITE() and load a sprite into memory, which is actually an animation sheet bitmap containing the frames for the enemy. On Windows, this works AMAZING. I can have a row of animation for each phase of an enemy - walking, being attacked, attacking, dying. for 4 frames in each row at 32x32 tiles, that's a 128x128 pixel image - nothing too intense. I can get a smooth 60FPS on iOS with this and all of the enemy coordinates are correct even with 90 enemies on the screen... but the actual images do not show!! On windows they do, and they show correctly. I've seen people having issues where the sprite was stretched or slightly skewed because of improper file types or resolutions, but in this case absolutely nothing shows up. Am I missing something obvious?

MrTAToad

Usually that happens with invalid coordinates (out of the screen area), invalid animation frame or GENSPRITE is returning -1...

Kitty Hello

Place images in the "Media" directory. Check for upper/lowercase file names.

Darmakwolf

Sorry to reply so late on this - it's solved now. Basically GLBasic doesn't always replace the copied media folder in the distribute folder. Can you give us an option to force GLB to delete the media folder and copy it every recompile? I'd really appreciate it and it'd save me some headaches...

erico

As of an option, like a check box, would be nice.

I have learned lately to enjoy the not-copying-media-folder thing, since I draw things upfront, and when testing/developing the game I want only to copy the new code, it serves me. But as said, an option would be nice to get more people happy :good:

Kitty Hello

I'll add an option to trashcan only media from the distribution, maybe?

ampos

On previous versions of GLB (before the distribute folder, I think) the media folder where always overwritten, that was ok for me.

BdR

Just wondering, so you do GENSPRITE and then load a sprite file with LOADANIM for each individual on-screen enemy? I'm assuming you don't have 90 different sprite sheets, so.. Wouldn't it be much more memory efficient to load the sprite sheet once, and then reuse that when drawing the enemies?

Darmakwolf

..... BdR - you made me realize that my enemy system is horribly inefficient in that respect. But my problem here is I don't have a clue how to fix that. Sure, it means more memory usage per enemy, to the tune of about 19 KB per monster on a map. That's not SO bad, but it could be significantly less. Here's my setup:

Game is told to load a room in the castle
game reads roomname.ini
roomname.ini tells game how many enemies there are
game initializes enemy array and reads individual monster info from separate monster.ini file
game loads spritesheet with gensprite for each enemy TYPE, loading an animation file for the monster based on its name

I do NOT wish to hard-code monsters. They are defined by ini files that point to an animation image. What I want to do is have it detect if a monster is using the same spritesheet as another and draw them all without having to have separate sheets in memory. What's the first step in solving this?



BdR

Sorry I forgot about this thread, okay let's see.. You could have two arrays

1) array of distinct enemy types
2) array actual individual enemies with screen position, state etc.

Then at level start, first load all distinct enemy types in the first array. So you'll need figure out somehow which enemies are needed for the level. After that load the actual enemies and instead of a property with animation sheet name, have a property with distinct-enemy-type index.

btw you could also do it the other way around: first load all individual enemies with the spritesheet names into a "sheetname" property or something. After that, iterate through all enemies and load the sprite sheets, checking each time if it is not already loaded (so it just loads once) and set the "enemy type" index.