Tresure Placement

For questions about using Classic.

Post » Thu Apr 01, 2010 7:42 pm

I want to place a treasure chest on my island. Because my island is so irregularly shaped my various land sprites (Forest, River, Mountains, and plains) over lap into my solid border.
I over exaggerated for this cap but want my treasure to be placed only on the island. Any suggestions?

http://www.box.net/shared/3br9bj9rel


I noticed that if I take the while out of the Start of Layout it runs fine but I do not want this using up resources. Unless I make a start up screen and them move to the game island screen.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154

Post » Thu Apr 01, 2010 11:02 pm

Hi. I took a look at that cap. I can't think of a better way to do what you are trying to do, but I do know how to make it work.

[quote="Guyon":1jbp0dm5]
I noticed that if I take the while out of the Start of Layout it runs fine but I do not want this using up resources.[/quote:1jbp0dm5]

Actually, it will only run once if you take the while out, so sometimes it would be placed incorrectly.

Anyway, I've noticed before that While doesn't act as I would expect. If you replace While with Repeat 1000 times it will work. It does not hurt to specify so many iterations, because once the overlapping condition is done, Construct will move on and not see that event again...

[code:1jbp0dm5]+ System: Start of layout
+ System: Repeat 1000 times
+ TreasureSprite: TreasureSprite overlaps BoundtySprite
-> TreasureSprite: Set position to Random(640), Random(480)[/code:1jbp0dm5]

EDIT - I might add, if the island in your main cap presents a small target for the random number generator, you should probably specify a significantly larger Repeat number in order to make sure to hit it.
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Fri Apr 02, 2010 2:07 am

But isn't that the object of a while? To run until it its condition is satisfied?

BTW what I meant about taking the while out is... I removed the while statement from the Start of layout. Strangely it works fine.
B
28
S
8
G
8
Posts: 530
Reputation: 7,154


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest