Generate non-overlapping objects

Game Editor comments and discussion.

Re: Generate non-overlapping objects

Postby lverona » Thu Jan 31, 2013 7:19 pm

Works. Thank you very much for responding in such detail!
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Generate non-overlapping objects

Postby lverona » Thu Jan 31, 2013 8:21 pm

One more clarification, to understand how gE works here.

In this code:

Code: Select all
if(CollisionFree(ball.clonename, ball.x, ball.y+5)


does gE understand that ball.x is really ball.clonename.x?
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Re: Generate non-overlapping objects

Postby skydereign » Thu Jan 31, 2013 9:34 pm

Yes, but ball.clonename is just a string variable. So, it really isn't ball.clonename.x, since a string isn't a struct, and doesn't have a x variable. But, just for the same reason ball.clonename gets you the correct clonename, ball.x will get you the x of the same clone.

Using an actor's name to get variables (for instance ball.clonename) uses gE's default actor struct. In most cases, that default struct will be equal to the struct of the lowest cloneindexed actor of that name. So, ball.clonename will usually be ball.0 (or ball.n, n being the lowest cloneindex of the ball actor). But, CreateActor will update the default struct to be equal to the highest indexed clone (since a newly created clone will always be the highest indexed). This is what you are using. So the struct can never point at multiple different clones.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Generate non-overlapping objects

Postby lverona » Fri Feb 01, 2013 5:38 am

Wow, this is some sophisticated stuff! And very useful knowledge. I should probably write a simple tutorial on this, because this is super useful stuff, being able to address latest created clone.
lverona
 
Posts: 221
Joined: Tue Apr 24, 2012 11:54 am
Score: 1 Give a positive score

Previous

Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest