• 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!

Resizing objects through scripting ...

W

wbhyvong

Guest
I want to increase or decrease the object size over time, so how to write code? please help me, very thanks!tau1.gif

if ………………….? What to write here?
{
image_xscale *= 1.5;
image_yscale *= 1.5;
}
 
Last edited by a moderator:

KurtBlissZ

Member
Lots of ways to do it, think this may be the more cooler one is to use the lerp function like this.
Code:
var target_scale = 5;
var target_rate = 0.2;
image_xscale = lerp(image_xscale, target_scale, target_rate);
image_yscale = lerp(image_yscale, target_scale, target_rate);
 

Sergio

Member
I want to increase or decrease the object size over time, so how to write code? please help me, very thanks!View attachment 16699

if ………………….? What to write here?
{
image_xscale *= 1.5;
image_yscale *= 1.5;
}
I also think lerp is better but the effect is the opposite, very fast at the beggining and slower after. If you want to do by your way, faster on each iteration, the if could be something like this

Code:
var target_scale = 5;

if (image_xscale < target_scale)
    image_xscale *= 1.5;
else
    image_xscale = target_scale;

image_yscale = image_xscale;
 
Last edited:
W

wbhyvong

Guest
Thank everybody,
I want to increase or decrease the object size by near or far position, so how to write code? please help me, very thanks!
 

Sergio

Member
For example, you can calculate the distance between your object position and the reference position, and divide the scale by that distance, being careful with distance = 0.
 
W

wbhyvong

Guest
How to set the number of bullets for the player?
code:
abc=instance_create(x,y,obj_danxanh)
abc.speed=25
abc.direction=point_direction(x,y,mouse_x, mouse_y) + irandom_range(-3,3)
abc.image_angle=abc.direction.
 
W

wbhyvong

Guest
Do not panic so that when the ship moves out of the room, it turns itself back?
And how does the ship move to a certain position when it goes back to itself?
 
These scattershot questions are confusing and we have no real way of knowing exactly what you mean. Even if english is your second language, you'll have to spend a little more time thinking about how to structure the question so we can understand what's going on properly before we can help. For instance, why is Don't Panic written in big friendly letters on the front of your last post?
 
Code:
image_xscale = target_scale
Will make the sprite appear facing one direction and
Code:
image_xscale = target_scale*-1
Will make the sprite face the opposite direction.
 
Top