• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Zooming function help

V

VansiusProductions

Guest
Hi guys,
I have an object called obj_circle.
Its parent is an object called obj_parent.
It has a draw event that has a code:
Code:
draw_set_colour(c_white)
draw_set_font(font)
draw_set_halign(fa_center)
draw_sprite_ext(sprite_index,image_index,x,y,global.scale*diameter/sprite_width,global.scale*diameter/sprite_height,image_angle,c_white,1)
draw_text(x,y+sprite_height/2+18,string(name) + "#" + string(diameter) + string(unit))
Then I have an object called obj_global, it doesn't interact with other objects. It sets global.scale when the room starts. Also, I have 2 events mouse wheel up and down. For mouse wheel up I have a code:
Code:
global.scale += 5
with (obj_parent) scr_render()
The script scr_render is as follows:
Code:
image_xscale = global.scale*diameter/sprite_width
image_yscale = global.scale*diameter/sprite_height
draw_sprite_ext(sprite_index,image_index,x,y,global.scale*diameter/sprite_width,global.scale*diameter/sprite_height,image_angle,c_white,1)
It redraws all the objects according to global.scale.
Basically when you scroll your mouse, the objects get smaller or bigger, depending on global.scale.
However everytime I do that the objects get flashy and sometimes it zooms in and out like inverted. This system is probably not the best and I would appreciated if anyone can help me.
 

Phil Strahl

Member
So you are calling scr_render() from the mouse wheel events? Because note that the draw_sprite_ext() function won't get executed unless you are calling it in the Draw events. I don't have time right now to look at your code in detail right now, but I feel there are possibilities to improve upon your implementation.
 
Top