Platform behavior - checking states from Python

For questions about using Classic.

Post » Mon Sep 06, 2010 5:43 pm

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: [code:25j8wou7]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.
B
2
G
2
Posts: 14
Reputation: 678

Post » Mon Sep 06, 2010 8:38 pm

If a Sprite has the Platform movement then it's done like this:
[code:31kd3wv5]SpritePlatform.IsOnGround()[/code:31kd3wv5]

I recommend trying out Silent Cacophony's Pyshell 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
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Sep 06, 2010 9:16 pm

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?
B
2
G
2
Posts: 14
Reputation: 678

Post » Mon Sep 06, 2010 9:43 pm

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.
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Mon Sep 06, 2010 9:46 pm

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.
B
2
G
2
Posts: 14
Reputation: 678

Post » Mon Sep 13, 2010 8:42 pm

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]
......
B
1
G
2
Posts: 8
Reputation: 641


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests