# Random Postions

0 favourites
• 17 posts
From the Asset Store
Easily generate many levels from a set of pre-built scenes (Construct 3 template)
• How do I get random positions to make a slot machine?

I've looked at examples but I still don't understand how it works...

• If you want a integer number, variableA = int(random(first number,last number));

Do the animation for each number, make them animate when his number is selected for that slot and you will achieve what you need.

When variableA = 3 on slot 3, play animation of diamond.

• That makes no sense to me?... I don't understand code, I have a single image with 5 different fruit and the 6th is the same as the first fruit. I want it to spin and stop on a random fruit each time. (No Animation)

• Do you have any .capx?

• .capx

I have spin part but its going the wrong way so I need to change that aswell.

• Try dividing the height of the sprite, by how many different tiles you have.

If your image was 4 pixels high you could say sprite set y to y+(-4+random(4))

• I'm not one for maths, the height is 6144 so I assume this is correct:

sprite.Y+(-1024+random(6))

I have 5 different fruit and a 6th which is the first fruit for the loop.

• More like .y+((-6(random(6))*1024)

.y+(random(-6,6)*1025) will work as well.

If the return from the random was 1 then 1024 * 1= 1024, if it was 2 it would be 2048, or the second tile.

Keep in mind the negative is there for relative placement, like if the image was already placed at the third tile place.

• If its not to much trouble could you implement it into my .capx file above?

Cant seem to get it to work, Id like it to stop aswell and then on-click start rotation again.

• Thanks Telles0808 but how do I keep the spin cycle working with what you just produced?

• You can setup different. Unlike to "Set Y", use the system to scroll down like you did before or use the behavior of 8 ways and check sprite position, when near, decelerate, then stop.

I know, it's a bit hard to start, but you'll learn fast, because everything you need is there waiting to be used, unlike coding, where you need to know exactly what you're doing, C2 show you all the variables and possibilities, you just need to use them ^^

• I am designer and I'm cut out for all this event/code business. Still makes no sense to me. I picked Construct 2 coz its all visual based and makes things slightly easier but there's still events/code with expressions I don't know how to use.

Code never works for me so I stay away from it...

• ## Try Construct 3

Develop games in your browser. Powerful, performant & highly capable.

Construct 3 users don't see these ads
• I just want something that works so I can do the part I enjoy! Making it look pretty! :)

• If you can design the animation between each slot (the scrolling animation), so, just make the "sprite" gadget with all the frames you need for each animation, like the first animation, you call it as Position 1 with a static animation of the first position, the second animation, Position 1 to 2, and make all the scrolling frames from the first to the second.

There on the code, just make it:

Event > Sprite is playing Position 1 > nothing inside the actions;

Subevent >> Mouse click down > Set animation to "Position 1 to 2";

If you separate every slot and make the transition scroll between each one I can setup it easy for you. As a game designer, you will not have trouble doing the animations, as you said.

• 17 posts