Need help in objects in Python

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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.

    <img src="http://s8.postimage.org/yedo99io5/Trail_Test.png" border="0" />

    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?

  • 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

    System.Create("Shot", 1, System.MouseX, System.MouseY )
    SOL.Shot.AngleTowardsPosition(640/2, 480/2)
  • I see.

    One more question:

    <font face="Courier New, Courier, mono">

    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;

    </font>

    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?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)