Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
Quiz in coppercube: shuffle array

downhill_92
Guest
Quote
2016-10-27 08:39:06

Hi everybody.
I would like to ask if it is possible to create a simple dynamic quiz with 2d overlay items.

I want to use five 2d overlays: the first, biggest, in the center of the screen will be the question, the other four will be answers of which only one will be the correct one.

This would be the solution:
🔎︎


I would like to make dynamic the order in which every answer appear in the 2d overlay.


So, how can I mix/shuffle it, whenever I open the game?

I made 4 variables that are 4 answers, but how to assign four variables to four 2d overlays in a random order?

The four variables are: ans1, ans2, ans3, ans4.
The four 2d overlays are: over1, over2, over3, over4.

I hope you understand what I mean.

Thanks to all those who will try to help me :)


erik
Registered User
Quote
2016-10-27 10:56:39

Maye you could just flip their positions randomly? That would probably be the easiest method.


downhill_92
Guest
Quote
2016-10-27 11:48:33

Thank you erik for you reply.

How can I do this? How can 2d Overlays be flipped randomly?


just_in_case
Moderator
Quote
2016-10-27 17:57:08

Use the scripted action set a random value...

And choose a variable and value from 0-4 and then if variable name = 0,

Then change position of the scene nodes... And then change or shuffle the position of your 2d overlays...

And do the same with value 1,2,3,4 and you are done.


downhill_92
Guest
Quote
2016-10-28 08:21:57

Thank you just_in_case,

I tried to do it in your way, but for me it didn't work :(

It works for other scene nodes, but not for 2d overlays...

Also the description of this action is:

Change Position of a Scene node
Lets a 3D scene node change its position. Based on the settings set, it is possible to set it to a new fixed 3d position or relative to another position ....


So this works only for 3d scene nodes, not for 2d overlays


downhill_92
Guest
Quote
2016-10-28 09:05:57

I solved in this way:

Set random value at the beginning of the scene (from 1 to 8), then if this value = 1, execute javascript:
var shuffle = ccbGetSceneNodeFromName("my2dOverlay");

ccbSetSceneNodeProperty(shuffle, "Pos X (percent)", 'myXPos');

ccbSetSceneNodeProperty(shuffle, "Pos Y (percent)", 'myYPos');


Then I did the same for all 2d overlays and all random values...


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Internat?onal" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact