How to create tiled sprites with random height?

Hi to all
I’m working on a simple test game and want to place some random tiled sprite in scene with random position and height.
part of positioning objects of my code work o.k, but all objects created in scene are with same height?
I attached three screenshots of preview that show objects created with correct random position and angle but with same size!!

I attached a screenshot of my code also.

what is wrong in my code?

I think if you try to scale your sprite in this way, your ladder will look very distorted! What you should probably do is draw another copy of the same ladder sprite, at the same angle, at an appropriate distance that they look to be linked into one larger ladder.

You can something like:

[code]Variable(ladder_height) = 1 + Random(3);
Variable(i) = 0;
Variable(ladder_x) = Random(10) * 10;
Variable(ladder_y) = Random(10) * 10;

while(i < Variable(ladder_height)
create object ladder at Variable(ladder_x), Variable(ladder_y);
Do + 40 to Variable(ladder_x);
Do + 40 to Variable(ladder_y);

The above code will need some adjusting on the +40, +40, depending on the angle. Yay Math :slight_smile:


Go in your favourite image editor and make some ladders of different heights and choose which one you want with a single random number.

I think event 4 is the problem as it will set all ladders to the last height chosen. Try deactivating it and see if that solves the problem.

thanks for reply :slight_smile:
since ladder is a tiled sprite, so scaling it wouldn’t make it look distorted,as seen in two preview image already attached.also i want ladders be random size and walkable, therefore i must use tiled sprite with random length(height)

Thanks very much
it solved the problem :slight_smile: :slight_smile:

Is any way to change anchor point of tiled sprite object for rotation, to a desired(say [0,0])point?
by default it is at center of sprite.

Objects rotate around the centre point, but you can manually move the centre point to a different position.

Double-click on the object in the objects editor panel. In the window that opens click the icon that looks like a + with a square around it. Then click the word Centre in the panel on the right. Anywhere you click with the mouse will now become the new centre point and therefore the new point around which the object will rotate.

No, you can’t modify the tiled sprite points, the origin is at (0;0) and the center at (width/2; height/2) :frowning:

Ah, that’s annoying. It’s like the fact you can’t alter the collision box for tiled sprites either.