Python - hinge problem

For questions about using Classic.

Post » Mon Nov 21, 2011 10:27 am

Hi there,

I would like to use the hingetoobject function, but I don't know how to access one of the istances. I searched the forum for hours, but I got nothing, so any help would be great..

I can access the first object(wich I want to hinge to the other object), but I don't know where to go from there.

Here is the snippet:

for i in range(0, 5):
     System.CreateByName("chain", 1, Sprite.X, Sprite.Y + 100 + i*chain.Height)
     SOL.chain.SetValue('ID', i)
     SOL.chainPhysics.HingeToObject("chain",0,0)

How can I reffer to a specified instance of the chain object?
B
10
S
6
G
3
Posts: 127
Reputation: 2,481

Post » Mon Nov 21, 2011 10:14 pm

I was going to say that you would need to use events for that but then I found a solution:
[code]for i in range(5):
   System.Create("chain", 1, Sprite.X + i*32, Sprite.Y)
   SOL.chainPhysics.DisableCollision("Sprite")
   if i == 0:
      SOL.chainPhysics.HingeToObject("Sprite",0,0)
   else:
      prev_chain.HingeToObject("chain",0,0)
   prev_chain=SOL.chainPhysics[0][/code]
It attaches the first link to the sprite object.
B
79
S
24
G
54
Posts: 4,753
Reputation: 40,769

Post » Mon Nov 21, 2011 10:36 pm

Wow, thanks for the help, it works like a charm.:)
B
10
S
6
G
3
Posts: 127
Reputation: 2,481


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests