Making an object "fall" [FIXED] [New Problem]

For questions about using Classic.

Post » Fri Jan 09, 2009 2:52 pm

[quote="PixelRebirth":1yqw8usw]I kind of get the impression you want Construct to magically know which sprite you actually mean, no offense intended. But if you're using improper conditions your events won't do what you want them to.

Maybe you could post the cap, so people could give you examples on how to fix it.[/quote:1yqw8usw]
I am aware of this, my question actually was if there was a way to get an instance of a sprite in the event editor, but apparently there isn't :/ Since the engine itself (obviously) knows how many instances of a sprite and their properties on the layout, the editor should have a way of picking these.
B
1
G
3
Posts: 8
Reputation: 841

Post » Fri Jan 09, 2009 3:02 pm

Why don't you just store the distance between player and enemy in a private variable (of the enemy). Then you check the distance and if it's below a certain number of pixels and Player.Y is greater than Enemy.Y => enemy attacks. Just an example. Could be more specific about it if you posted the cap.

I have a distance value to all my enemy sprites, since it's useful in many situations.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Fri Jan 09, 2009 3:07 pm

[quote="PixelRebirth":4onr9vfs]Why don't you just store the distance between player and enemy in a private variable (of the enemy). Then you check the distance and if it's below a certain number of pixels and Player.Y is greater than Enemy.Y => enemy attacks. Just an example. Could be more specific about it if you posted the cap.

I have a distance value to all my enemy sprites, since it's useful in many situations.[/quote:4onr9vfs]
Yes, it's a possible way, problem is i'm used to programming where i can just create a function/class and re-use it at a later time. If that was possible here it would be so much easier ^^
B
1
G
3
Posts: 8
Reputation: 841

Post » Fri Jan 09, 2009 6:05 pm

Why would you not be able to reuse it? Just recalculate the distance variable to be stored as needed.

And there is a function object that creates functions you can call on any time, fyi.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Jan 11, 2009 6:20 pm

Also, if you'd like to create "Objects" in the sense that Object Oriented Programming uses the word (where you can assign functions and even other objects to an object) then in Construct try putting everything into a container and think of that as your "Class".
B
3
S
2
G
4
Posts: 271
Reputation: 2,017

Post » Mon Jan 12, 2009 9:47 pm

At the moment you only seem to be checking if Player.x is greater or equal to Spike.Left. You'll need to add another condition checking if Player.x is lower than Spike.Right, that way it'll only pick the spike that you're within the bounds of.
B
2
S
1
G
5
Posts: 59
Reputation: 1,518

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 6 guests