Construct 2 - One Trick Everyday #14 - Random images, no repeat

Stats

398 visits, 439 views

Translations

This tutorial hasn't been translated.

Tools

Hi All,

I am back with Season 2 of my series 'Construct 2 - One Trick Everyday'. Today gonna share a new trick for showing images with no repeat. I am sure many of you would have tried generated random no. and mapped an image to show accordingly but it always repeat the same image or no. instantly. Forexample, instead of showing series 1,3,5,4,7 construct 2 would have shown randomly 1,3,3,4,5,5. I faced this issue many time and thought can share it with all my friends here. Steps follows like this

1. Create sprite with as many frames as you want. I took sprite with no. 1,2,3,4,5. You can see that in video.

2. Create local variable.

3. Assign it to sprite.animationframe

4. Add a while loop, with add another condition local variable = sprite.animationframe. Basically we are telling loop to generate random no. if we find new number and previously generated number was same. If not then generate new number or show new image.

I know reading is very difficult and sometimes difficult to understand too so you can see my video of the solution here youtu.be/b2EwQS7RfSM

Also you can download capx from here

  • 0 Comments

  • Order by
Want to leave a comment? Login or Register an account!