Help - Search - Members - Calendar
Full Version: Creating New Sprite Then Drawing It
Game Maker Community > Working with Game Maker > Advanced Users Only
_Jaiden
Here is the code I am using:

Create Event:
CODE
joke = sprite_add("joke.bmp",1,false,false,false,true,0,0);
alarm[0] = 30;


Alarm 0 Event:
CODE
draw_sprite_ext(joke,-1,16,96,0,0,0,c_white,1);


I also tried this in Alarm 0:
CODE
draw_sprite_ext("joke",-1,16,96,0,0,0,c_white,1);


But nothing works. When I run it, I get the message "trying to draw non existing sprite".
Anybody who can help me?

Thanks,
- Jaiden
Him
Everything you used (aside from the last one) works correctly as it should, assuming "joke.bmp" is in the working directory of the game. However, you are drawing this sprite once, when the alarm goes off, and when Game Maker is not refreshing the screen. You will never see the the image for the fraction of a second it is being drawn for, unless you call screen_refresh() in the alarm event after drawing the sprite or use draw_sprite_ext() in the Draw event.

Your last attempt:
CODE
draw_sprite_ext("joke",-1,16,96,0,0,0,c_white,1);
Does not work, because a string cannot equal an index of a sprite.

Please note that you have both the horizontal and vertical image scale set to 0 in the draw_sprite_ext() function and therefor the image will be scaled to zero width and zero height.
_Jaiden
ahh of course! thankyou for reminding me of that.
The silly mistakes I make...
PS: I also made a stupid mistake conserning png file extensions wink1.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.