How do I add score for pickup on different objects

Get help using Construct 2

Post » Sun Oct 23, 2016 4:33 pm

I have 3 different size disks - small, medium and large. On start of layout a blue star is created for each and every disk, then pinned to that disk. When the player rolls onto a disk and is overlapping a star it adds to score. But since these different sized disks can overlap each other, as if they were on different layers (they are on the same layer) how can i differentiate what star is pinned to what size disk?

Example - large disk with star is worth 1000 points, medium = 2000, small = 3000.
If there are 2 large disks, one on top of another, and a small disk underneath those two large disks, and the player rolls onto the top most large disk, he should score 5000 points. Large =1000 + large = 1000 + small = 3000.

I know i'm going to need a variable, but i can't seem to get this right, since . . . well . . . i don't know what the hell i'm doing.


Any help is immensely appreciated.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Oct 23, 2016 5:14 pm

How I would do this depends on how much the star matters. Can you overlap a disc without a star being on it for less points? If each disc always has a star pinned to it then the star doesn't really matter does it and is only a visual thing, it's just the disc that matters and you award points based on the disc type being overlapped.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Sun Oct 23, 2016 5:22 pm

You can get the pinned UID when you use the pin behaviour.

For instant:

Code: Select all
On start of layout
      Pin object_1 to object 2

On key pressed 'A'
     text1.text = str(object_1.Pin.pinnedUID)  <-- (Will set Text1.text to the UID of object2, you can use this to pick the correct disc and then get the correct size/score)

B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Sun Oct 23, 2016 5:41 pm

plinkie wrote:How I would do this depends on how much the star matters. Can you overlap a disc without a star being on it for less points? If each disc always has a star pinned to it then the star doesn't really matter does it and is only a visual thing, it's just the disc that matters and you award points based on the disc type being overlapped.



Damn it @plinkie - you just made my brain hurt. I never even thought of it like that. Always the wise one.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Oct 23, 2016 5:59 pm

nimos100 wrote:You can get the pinned UID when you use the pin behaviour.

For instant:

Code: Select all
On start of layout
      Pin object_1 to object 2

On key pressed 'A'
     text1.text = str(object_1.Pin.pinnedUID)  <-- (Will set Text1.text to the UID of object2, you can use this to pick the correct disc and then get the correct size/score)



You can see how i the stars and disks overlap.

Image

There isn't a key press. The game will use tilt for the gameplay and On Tap Object - Play - that will take the user to the main layout. This is how i have the pin event right now:

Image

I just made 3 more families - LgDisk, MdDisk and SmDisk. So i should be able to change and add 2 more events for - System - For each LgDisk/ MdzDisk/ SmDisk.

And forgive me @nimos100, i'm not understanding your text1.text = str(object_1.Pin.pinnedUID)

Can i trigger that with - LgDisk > On Created?

Thank you for the replies.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Oct 23, 2016 6:27 pm

@plinkie

On 2nd thought, the star does matter. If there was no star then the player would only have to come into contact with the disk to score. With the star the player needs to make it to the center of the disk.

Besides, people love collecting things.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Post » Sun Oct 23, 2016 6:34 pm

Because you are pinning the star at image point 0 the origin, you can say when the player overlaps the disc at image point 0 as well.
B
45
S
15
G
73
Posts: 2,007
Reputation: 43,396

Post » Sun Oct 23, 2016 6:40 pm

You could make 3 identical star objects and put each in a container with a different disk. That will make the star pick the right disk automatically (if you pick by object. It doesn't work by family). You will also make a star spawn automatically (though you will still need to pin it) whenever you spawn a disk.
Eh, Steve!
B
113
S
54
G
13
Posts: 112
Reputation: 16,090

Post » Sun Oct 23, 2016 6:40 pm

I just made 3 more families - LgDisk, MdDisk and SmDisk. So i should be able to change and add 2 more events for - System - For each LgDisk/ MdzDisk/ SmDisk.

And forgive me
@nimos100
, i'm not understanding your text1.text = str(object_1.Pin.pinnedUID)

Can i trigger that with - LgDisk > On Created?


Sorry was just using a textbox as example.

My point were as you pin one object to another, the object that you pin the object to can be received, since that is the case you can get the size and thereby add the correct score.

Here is a simple example:

https://dl.dropboxusercontent.com/u/109921357/Get%20pinned%20UID/Get_pinned_UID.capx

If you click one of the stars (Blue circles) you get a text showing its UID and the UID of the disc that its pinned to as well as the size of the disc. Which if I understood you correct would decide the score.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828

Post » Sun Oct 23, 2016 7:19 pm

@plinkie @calebbennetts @nimos100

Thanks for all the help. At the start i was just planning on the AllPlats and Stars giving a general score, but since decided to try and add combos.

This is why i think i need to pick the size of the disk.

And i forgot all about containers. Gonna try and get the logic right for the ComboMultiplier.


Thank you again for the help. Much appreciated.
B
38
S
18
G
19
Posts: 664
Reputation: 14,107

Next

Return to How do I....?

Who is online

Users browsing this forum: DarkRoomGames, mekonbekon, NadeemAbbass and 10 guests