Platform behavior - checking states from Python

This forum is currently in read-only mode.
From the Asset Store
Wanting to do a Shot n Run game easily? Here is your chance!
  • Hello all, I'm brand new to Construct - a veteran of Game Maker, so far I like Construct a lot more.

    My question relates to how Python can access certain information from an object's added behavior. The built in platform behavior has several states that can be checked (if player is falling, if player is on ground, etc.). I'm wondering how to check these states from python... so far, all I have is:

    if Player[Platform].[/code:25j8wou7]
    lol and don't know where to go from there.  I'm big on code and enjoying learning Python and want to figure out how just how capable it is in duplicating what the events system can do.
  • If a Sprite has the Platform movement then it's done like this:

    I recommend trying out Silent Cacophony's [url=]Pyshell[/url] for experimenting with python.  I use it whenever I use python in my caps to see the correct name of attributes and to see what's accessible.
    To find the names of all the attributes of SpritePlatform:
    * Open PyShell.cap
    * Add a Sprite object and give it a Platform Movement.
    * Run the cap
    * Type in "dir(SpritePlatform)" and press enter.
  • I did what you said and it doesn't work.

    I opened pyshell, created a sprite called Player, added the platform behavior...

    dir (Player) - worked, gave me all the general stuff (no platform stuff)

    dir (PlayerPlatform), dir(Player.Platform), dir(Player[Platform]) <- these all just gave me errors

    also can't get IsOnGround() to work in my game. tried all the combinations of Player and Platform as I did with pyshell. What am I missing here?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What version of Construct are you using? You will need at least 0.99.93 to be able to access behaviors like that in python.

  • 0.99.91 is the version I'm using, since it's the latest stable release... but thanks, I'll go ahead and download the latest build.

  • This works great, however what do you do when you have multiple sprites? How do you access the behavior of the second sprite?

    *edit* Similar syntax to the normal stuff




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