Improved Sprite Stacking
A downloadable Gamemaker script
IMPORTANT
For this script to work (and any other script involving draw_sprite_pos), you have to go to Tools > Texture Groups and turn Automatically Crop to OFF. If you don't do this, all of your sprites will stretch into a square.
THIS SCRIPT IS NO LONGER BEING UPDATED.
INFORMATION
Sprite stacking is a method of drawing sprites popularized by Moppin's NIUM. The way it works is it takes many slices or cross sections of a 3D model and draws them in increasing heights to achieve a false 3D effect. Although there are many scripts trying to replicate this, there aren't many that squash the sprites as NIUM does it.
This script is inspired by NIUM's false 3D and Like 100 Bears' sprite stacking script. The main difference between this and Like 100 Bears' script is that this script uses Gamemaker's draw_sprite_pos function and the point_direction and point_distance functions to calculate the corners of the sprite for the draw_sprite_pos function. This has the effect of "tilting" a sprite on a faux 3D axis. A comparison can be seen in the video to the right.
HOW TO USE
To set up the sprite, follow this guide.
Stick this script in an object's Draw event. The variables are as follows:
x: sprite's x position
y: sprite's y position
(both of these will be the coordinates for the bottom layer)
sprite: the name of the sprite you want to stack
(as set up from the guide above)
SCALE: the 2D scale of the sprites, 1 being unchanged
HEIGHT: the space between the layers, should set it to the same as scale if you don't want to make it taller or shorter
rotation: basically image_angle
PERSPECTIVE: the angle the stacked sprites should be viewed from (0 is directly forward, while 90 is top-down view; I would recommend against low angles as you can start seeing the gaps between sprites)
alpha: alpha
HD: boolean: if set to true, it "doubles up" the sprites, reducing the moire pattern you see at low angles, at a cost of some performance.
Download
Click download now to get access to the following files:
Comments
Log in with itch.io to leave a comment.
TIMBERRR!!
hey its not working i put script in draw event and it doesnt show
I second that.
Hey! I have some issues... the code works like charm! But seems like the image_angle of a regular sprite is not equal to the image_angle of the script.
PD: I Reaaaaallly love your script! THANKS!
If the character is sliced into layers as it would be in typical sprite stacking, the whole character should be able to be rotated. Would you be able to elaborate?
For anyone seeing their sprites being stretched, try disabling "Automatically Crop" in your texture page settings... this took me a while to figure out
having issues as soon as I run the program.
ERROR in
action number 1
of Create Event
for object <undefined>:
dcos argument 1 incorrect type (undefined) expecting a Number (YYGR)
at gml_GlobalScript_Script1 (line 25) - var _perspectiveFront = dcos(_perspective);
############################################################################################
gml_GlobalScript_Script1 (line 25)
How did you implement the script? I.e. Can you copy/paste the line the error (where you called the script) is from?
Nice work on the ‘tilt’ effect, always cool to see more people giving this technique a go