Select a Random frame with no Repeats (no duplicates)

5

Attached Files

The following files have been attached to this tutorial:

.capx

random-norepeat.capx

Download now 646.11 KB
.capx

random-norepeat-begins-from-startoflayout.capx

Download now 646.22 KB

Stats

3,312 visits, 4,477 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 19 Apr, 2015. Last updated 19 Feb, 2019

.

.

So maybe you have a game that randomly selects a sprite frame (from a sprite that has many animation frames)

, and

as the game progresses you notice the same frames are being 'played',

even before the 'unplayed' frames.

It inevitable to happen since its random, right.

But

what you want is all the 'unplayed' frames to 'play' first in a random order,

then start from the beginning again in a different random order.

So I started playing with the C2 code and after 4 or so hours of getting nowhere I decided to ask the forum;

@korbaach kindly responded and sent me an entire game.

It had a thing I have never worked with before (Ajax) so I was a bit nervous and started to break down the code to the simplest (barebones) form and still have it work as intended.

After much trial and error and another several hours, Mission Completed

NO PLUGINS are REQUIRED. only 12 events

Anyway, I thought this barebones version could come in handy to other novice users like myself, so I asked @korbaach if it's cool to make a tutorial and he said, go for it.

Anyway, here are the pics:

.

for those like me who have you never worked with Ajaz before:

Here is where the txt file is located.

Important

You may need to remove the very first ' # 'at the beginning in that file to work for your game.

This 'game' needed it to make all 26 letters to appear, your game may not.

.

.

Important

One thing I discovered the hard way,

was that one of the text objects

(in the capx example: Text_TopicList)

needs to be in every layout that you want this action to happen.

.

.

Enjoy .....

2 capx files:

one happens on the first click

and the other happens from the start of layout

-

adjust the code as needed, as it will be a bit different for each game variation.

** edited and fixed mistake in the capx that prevented all 26 letters from displaying.

.CAPX

random-norepeat.capx

Download now 646.11 KB
.CAPX

random-norepeat-begins-from-startoflayout.capx

Download now 646.22 KB
  • 0 Comments

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