-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Function "sprite_add" Not Successfully Loading Sprites. #1060
Comments
Update: The issue appears to be with accessing sprites via their numeric indexes and not with assigning sprite index values to map. This issue is also present whole trying to assign sprites in the asset tree via their integer index. |
What is ENIGMA actually doing that you don't expect? The code you are running appears correct, ignoring the roundabout way you are changing your sprite's x and y offset. In fact, you might be tickling a bug, there. Does the issue go away if you remove that |
Yeah, after I posted it I realized there was an easier way to change the x and y offset. Removed it and issue still persists. Essentially if you do... It works find, but try and return a number representative of the sprite index for use in a draw function, such as the kind assigned based on the resource position in the list, and it immediately crashes at runtime. |
Well, |
I printed the value in the program using draw text. |
There may be some sort of corruption happening in the internal sprite storage. How many sprites are you adding after the one that crashes the game when you go to use it? Does just adding that many sprites and drawing the first of those cause the crash? |
That was my thought just now. I'll test the script when at my computer later further. As far as I know the issue happens when the value is returned from the script and used in the draw function. I imagine it is an issue with loading but will collect more info later. |
Right now I'm only loading 1 sprite and then attempting to draw it. |
So yeah, I've done further testing (drunk testing so take with a grain of salt) and the issue appears to be with the If you were to try to assign an invalid / non-existing sprite asset index to the So it appears the issue lies within the |
If it's only one sprite, then there's no reason at all that accessing it by that return value would behave differently than accessing it from the map. If the value returned by |
Also, what graphics system are you using? GL3? |
I've uploaded the /revisied/ script to Pastebin for easier reading, since Github appears to be mis-formatting it. I got rid of unnecessary stuff like humanizing the map string to only include the file name, since it would have caused unexpected conflicts with items in other folders using the same filenames. I also ditched the re-loading of the sprite and no longer delete anything while loading. The issue still persists loading like this, regardless. In the attached screenshot I am printing the sprite index to the screen as well as conditional check that only shows based on whether or not the runtime thinks the sprite exists. In my project I only have 1 sprite held within the IDE, that being the no_sprite sprite. All other sprite assets are to be loaded externally. As I started this project a day ago I'm currently only trying to load 1 sprite, ergo why I found this error. With the script returning 1 we can assume it at least thinks its loaded it, as the sprite_exists has been tested at multiple stages of loading the image. Even after the initially load it still thinks it's there. Nevertheless, the game would freak out if I were to use that asset ID in a draw_sprite function, like it would if the asset index didn't exist. I'm using GL1.1 right now. I'll try with another one and report my findings. |
The issue persists with OpenGL 3.3, instantly crashing at runtime like 1.1. OpenGLES fails to compile, due to it not being able to find any of its headers in "Graphics_Systems/OpenGLES/". I suspect this particular one may just be me missing the dependencies to compiler with it, however. |
Okay. At least there's consistency. I have no idea what's wrong, but looking at the code, I see a lot of failure surface. For starters, the sprite system is doing its own memory management. There's just no need for that. I'll see about getting that patched over in a pull request later this week. |
I see that significant time has passed without any updates to this issue and I am going to close it. We've made several changes to the sprite functions (including
|
So I often load sprites externally in Game Maker like so...
ds_map_add(Game.sprite,varName,sprite_add(varPath,varImgs,false,false,varX,varY,false));
Creating a sprite dictionary, and running a check to see if the sprite name already exists, if so, reusing the resource already allocated. Enigma, however doesn't seem to like this.
Here's the full code snippet, in case further elaboration is needed.
/// sprite_get(path,img);
var varPath = argument[0];
var varImgs = argument[1];
var varX = 0;
var varY = 0;
var varSprite, varName, varBreak;
if (Game.sprite > -1) {
// Grab the position of the last slash in the path.
for (var i = string_length(varPath); i > 0; i--) {
if (string_char_at(varPath,i) == '/' || string_char_at(varPath,i) == '') { //'
varBreak = i;
break;
}
}
// Set the map index name to file name.
varName = string_copy(varPath,varBreak,string_length(varPath));
}
return no_sprite;
The text was updated successfully, but these errors were encountered: