Need help in objects in Python

For questions about using Classic.

Post » Thu Jun 14, 2012 4:03 pm

I am trying to create trails with shot objects. The shot objects will have trails behind them. They are basically Sprites, nothing more.

It works fine with event sheet, but it does not with python script.



If you hold left click, you will have constant stream of shots with trails object. (I use MouseKeyboard.AbsMouseX and MouseKeyboard.AbsMouseY)

However, if you right click, shot objects will be created via Python script. Yet, the trail objects will not appear from these shots UNLESS the user stop holding the right click.

What is going on here in Python script?akaja2012-06-15 05:12:41
B
2
G
1
Posts: 38
Reputation: 526

Post » Thu Jun 14, 2012 7:19 pm

With events the picking is reset between toplevel events. The picking doesn't seem to be reset when creating objects in python. Fix it by adding a "For each MouseKeyboard" condition so that the picking gets reset. You can replace MouseKeyboard with any single instance object, the point is For Each resets the picking.

+ System: For each MouseKeyboard
+ MouseKeyboard: Right mouse button is down
[code]System.Create("Shot", 1, System.MouseX, System.MouseY )
SOL.Shot.AngleTowardsPosition(640/2, 480/2)[/code]
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765

Post » Fri Jun 15, 2012 11:10 am

I see.

One more question:


if (MouseKeyboard.KeyDown(19)):
     System.Create("Shot", 1, MouseKeyboard.AbsMouseX, MouseKeyboard.AbsMouseY );
     Shot.Angle = 270;
elif (MouseKeyboard.KeyDown(20)):
     System.Create("Shot", 1, MouseKeyboard.AbsMouseX, MouseKeyboard.AbsMouseY );
     Shot.Angle = 90;


How can I refer to the objects in Python script? The above code gives me error. If you put this code in, sometimes, one random Shot will change angle.

This is picking problem again. How can I refer to the Shot that has just been recently created in Python code here?akaja2012-06-15 11:20:43
B
2
G
1
Posts: 38
Reputation: 526

Post » Fri Jun 15, 2012 5:29 pm

Use SOL.Shot.Angle=90. SOL stands for selected object list and when you create an object it becomes the only picked object of that type.
B
79
S
24
G
54
Posts: 4,751
Reputation: 40,765


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest