Small question - picking a random object

For questions about using Classic.

Post » Wed Apr 02, 2008 5:00 pm

Deadeye's solutions are good so far, except that you can do it without subevents, heh - 'pick random' could simply be a condition after 'every'.

As for object picking via conditions, remember two things:
- For Each works best as the first condition
- Use built-in conditions wherever possible instead of System's Compare Values (eg. Sprite's Compare X rather than comparing Sprite.X to a value - works instance by instance)

Also might help to post your .cap file, so I can tell you exactly what's going on.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Wed Apr 02, 2008 6:38 pm

I couldn't really figure out containers. I assigned them and got the yellow box and everything, but it doesn't seem to register. I don't think it assigned them correctly, since I didn't really understand what you meant by:

[code:3o0z24j7]
+ objectBody condition
- objectSprite: Set position to objectBody
[/code:3o0z24j7]

Did you mean "always - set position"? because if I do that the containers seem to rapidly switch between sprites.

As for your question, construct does seem to detect when a platform object is on collosion with the ground, but only when it changes direction.

Edit: I found a way to work around it - when a platform object is "on the ground", it's Y velocity is set at 100. no need for detectors now, I think!
B
2
G
4
Posts: 44
Reputation: 1,138

Post » Wed Apr 02, 2008 7:48 pm

[quote="electrii":38bwfd1i]I couldn't really figure out containers. I assigned them and got the yellow box and everything, but it doesn't seem to register. I don't think it assigned them correctly, since I didn't really understand what you meant by:

[code:38bwfd1i]
+ objectBody condition
- objectSprite: Set position to objectBody
[/code:38bwfd1i]

Did you mean "always - set position"? because if I do that the containers seem to rapidly switch between sprites.[/quote:38bwfd1i]

I meant something like this:

[code:38bwfd1i]
+ objectBody.Value('status') Equal to "alive"
- objectSprite: Set position to objectBody
[/code:38bwfd1i]

The condition doesn't really matter as long as it's something that references objectBody. It could be "objectBody.Y Greater than 0" or "objectBody is visible" or something like that. If you want it to have an Always like effect, use a condition that will be consistent each cycle.

And yeah, you can do simple stuff to detect whether your sprite is on the ground. I use y position to detect whether my jack-in-the-boxes were jumping or standing still. I suppose you could do something similar for x position to detect walls, but it might just be easier to use detectors.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Apr 03, 2008 7:34 am

I'm guessing "body" is the active object and "sprite" is the skin?
maybe I should take a look at your cap when i'm home. containers look useful.
B
2
G
4
Posts: 44
Reputation: 1,138

Post » Thu Apr 03, 2008 7:51 am

Yeah, I use a separate collision sprite (just a simple rectangle) and position the animated sprite on top of it. The rectangle is the one that gets the platform movement and does all the work. The sprite is just there to look pretty.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Thu Apr 03, 2008 6:56 pm

Awesome, I figured it out. I think it solved my freezing solution, since a solid box collosion is much more stable than an animated sprite with pointy edges :D
B
2
G
4
Posts: 44
Reputation: 1,138

Previous

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest