Chance to stick?

For questions about using Classic.

Post » Fri Oct 08, 2010 4:48 am

I was wondering if anyone could suggest someway I could make it so that when 2 objects touch there's a chance for them to stick and be dragged, dropped and rotated as a single object?

Thanks in advance!
B
2
G
2
Posts: 11
Reputation: 672

Post » Fri Oct 08, 2010 11:17 am

That's a bit vague, how are they going to rotate, and whats the chance for a stick?

Without knowing much more I'd say take a look at the custom movement behavior.
There's an action called restrain distance from object.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Fri Oct 08, 2010 3:10 pm

Oh, sorry! Well I'm not 100% sure how rotation will work right now.

At the moment rotation is set up for the individual incomplete little pieces that are meant to attach and it works via a double click, I'm certainly willing to change this if it doesn't work out, though.

The chance for stick varies depending on the level, initially it's 50% and on the last level (15) it's 95%.

I'm going to look into the restrain distance action right now! I hope my specifications helped!
B
2
G
2
Posts: 11
Reputation: 672

Post » Fri Oct 08, 2010 3:15 pm

[quote="mugginbun":3qot0lqd]I hope my specifications helped![/quote:3qot0lqd]

It's still rather vague. It's best to give a general description of the actual gameplay you're trying to create and what is going wrong in creating it, like "I'm making a 2D Katamari clone, how do I get it to pick things up? I've tried X, Y, and Z but it doesn't work."
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Fri Oct 08, 2010 3:31 pm

Here's an example:

viewtopic.php?f=16&t=7468
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432

Post » Fri Oct 08, 2010 6:30 pm

Okay, I'll get into further detail! Also, thanks Arima, your tutorial gave me some ideas.

My idea for a game is a packing puzzle.
In this puzzle the game generates shapes composed of equilateral right angle triangles to fit into a square box.

When the box is filled the game advances a level. Advancement in level means that the box to fill is 1 unit larger in the x and y direction. I used an array to accomplish the changing size of the box.
An increase in level also indicates that more triangles are necessary to fill the box, not only that, but the triangles become capable of attaching to more adjacent triangles than before making for larger and more complicated shapes.

B
2
G
2
Posts: 11
Reputation: 672

Post » Fri Oct 08, 2010 7:25 pm

Hey I love those games >_< I want to play it!
I know, they're meant for kids, but there's something about them I really enjoy :P

if you want chance, you should use random(max).This generates a random number which you can divide by max to generate a chance.

Then, you'd have to do the stickin' by yourself :P
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Fri Oct 08, 2010 7:47 pm

[quote="madster":1azl5jw4]Hey I love those games >_< I want to play it!
I know, they're meant for kids, but there's something about them I really enjoy :P

if you want chance, you should use random(max).This generates a random number which you can divide by max to generate a chance.

Then, you'd have to do the stickin' by yourself :P[/quote:1azl5jw4]

I'll be sure to post it in the creations section as soon as it's done. :)
I was wondering, is there a command I could use to randomly generate a number between and including 1 and 100?
B
2
G
2
Posts: 11
Reputation: 672

Post » Fri Oct 08, 2010 11:41 pm

random(100)+1 :D
B
3
S
2
G
2
Posts: 136
Reputation: 1,347

Post » Sat Oct 09, 2010 11:27 pm

One way to have the pieces stick is to group them with a private variable. The only tricky part is setting the private variables so that the objects are in a clump.

I uploaded a working example here:
[url:2k1tgpfw]http://www.scirra.com/forum/viewtopic.php?f=16&t=7488[/url:2k1tgpfw]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest