0 Favourites

Platform behavior - checking states from Python

This forum is currently in read-only mode.
  • 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:

    SpritePlatform.IsOnGround()[/code:31kd3wv5]
    
    I recommend trying out Silent Cacophony's [url=http://www.scirra.com/forum/viewtopic.php?f=16&t=6158&start=0&hilit=pyshell]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.
    
    -cheers
  • 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?

  • 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.

  • Construct 3

    Buy Construct 3

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

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

    SpritePlatform[0]

    SpritePlatform[1]

    ......

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