How do I set array(x) equal to an selected image

Just started using Construct 2? Post your questions here

Post » Tue Jul 28, 2015 9:02 am

How do I make, an element of array, ex: array(x) equal to an selected image.
It's for my final project and I really stressfull, please help me solve my problem
B
6
S
1
Posts: 39
Reputation: 495

Post » Tue Jul 28, 2015 10:05 am

You can't. You can track using UIDs though, which can be stored in an array. Can you be clearer about what you want please ?
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Tue Jul 28, 2015 11:16 am

I have an array which is a file.txt, then I copile it with ajax. My array contents with question that I used for my trivia game. So when the question appear then player can clicked the answer, when the answer is an random image. the problem is I can't define my array so that the element can equal to an image
B
6
S
1
Posts: 39
Reputation: 495

Post » Tue Jul 28, 2015 11:22 am

Do you want to see my file.capx ?
B
6
S
1
Posts: 39
Reputation: 495

Post » Tue Jul 28, 2015 12:06 pm

Hi @FriskAS

You can store image *name* in the text file or array, and then use it e.g. to load the image from URL. You cannot store anything else than a string or a number in an array. As @paulscottrobson suggested, the number can be used to refer to another object UID. But in your case this seems overcomplicated.

If you have a set of pre-defined images, it might be easier to store them as separate animations in a single sprite, label the animations with image names, and then choose one of the images from the list. You could use the "choose" expression e.g. Sprite.SetAnimation(choose("image1","image2","image3")

Alternatively, you can store images as separate frames of a single animation, and then show a random one with Sprite.SetFrame(int(random(Number-of-Frames))
B
18
S
3
G
3
Posts: 83
Reputation: 3,736

Post » Tue Jul 28, 2015 4:47 pm

Wow thank you so much for all of your answer, I will try it !
So, I have question again if I have an quiz game, example :
Who is the first presiden of Indonesia Republic ?
A. Habibie
B. Soekarno
C. Jokowi
I used a file text as an array for my question. And an image for my answer, please tell me how do I make it ?!
B
6
S
1
Posts: 39
Reputation: 495

Post » Tue Jul 28, 2015 4:53 pm

Hi @CJK I seems didn't really understand your coding I'm a beginner, can you explain it more easier so I can undarstand ?
B
6
S
1
Posts: 39
Reputation: 495

Post » Tue Jul 28, 2015 5:08 pm

Hy again @CJK
When I read it again I seems understands, so I do have a set of pre-defined images, but I have 200 images, if I store it one by one in animation of a single spirite, oh God it's really will become a pain in the ass,
I need more easier process.
So by your definition, I can set, my question as text file and an answer as an image. Example :
A question(text file =>array) the answer is X(image)
B
6
S
1
Posts: 39
Reputation: 495

Post » Tue Jul 28, 2015 5:51 pm

Hi @FriskAS,

I'm afraid I do not understand you setup. What do you need the images for? In the item:

1: Who is the first presiden of Indonesia Republic ?
2: A. Habibie
3: B. Soekarno
4: C. Jokowi

line 1 is question, but lines 2,3,4 are answers. In my understanding, a quiz of this type would have each of the lines 2, 3, 4 as separate buttons with text labels, that are clickable.

What are images for in this setup? Are they big (photos) or small (icons)? Please tell me what you are trying to achieve in your project, maybe then I'll be able to help.
B
18
S
3
G
3
Posts: 83
Reputation: 3,736

Post » Wed Jul 29, 2015 3:51 am

hi @CJK
What I want in my project is that I can make the answer of the question with an image, its just small image. So the player can choose the answer by clicking the image which is represent the answer.
Example is, the photo of Habibie, or the photo of Soekarno.
I think it's gonna more entertaining if the player knew their picture.
B
6
S
1
Posts: 39
Reputation: 495

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests