Results 1 to 6 of 6

Thread: Beginners Question regarding CL_CollisionOutline & collide

  1. #1

    Default Beginners Question regarding CL_CollisionOutline & collide

    I tried to implement a collision check between player&meteor for a simple 2d space-shooter, but I have serious problems to access the attributes from my class but I guess its better if I start with posting my code:

    Code:
    //Check Meteor Collisions
    			for(int i = 0; i < NUMBER_OF_METEORS; i++)
    			{
    				if( (player->outline)->collide(meteor[i].outline) )
    				{bla bla...}
    			}
    Error Code: : error C2664: 'CL_CollisionOutline::collide' : cannot convert parameter 1 from 'CL_CollisionOutline *' to 'const CL_CollisionOutline &'

    I understand the error text somehow but I have no clue about how I could implement this.

    I know this is not really a Clan-Lib problem but maybe you can help me anyway

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    Try:

    if( (player->outline)->collide( * meteor[i].outline) )

    ( '*' dereferences the pointer)

  3. #3

    Default

    Yes it works, thank you
    The problem I have now is the following: The Collision Detection only works for meteor[9] (the last one NUMBER_OF_METEORS = 10), but I hope I can find a solution myself.
    Anyways maybe someone likes to help

    edit: Another Question, can I make the CollisionOutlines visible so I can check if they're moving with the meteors in the right way?

  4. #4

    Default

    Hey its me again

    I continued working on this game and again I'm having problems with the collide function

    Code:
    list<CMeteor *>::iterator it;
    	for(it = meteorList.begin(); it != meteorList.end(); ++it)
    	{
    		(*it)->move(DOWN);
    
    		if( (*it)->outline->collide(player->outline))
    			(*it)->setSpawnPoint();
    
    	}
    As you can see im working with lists now.
    When im using point_inside instead of collide it works:
    Code:
    point.x = player->getX();
    	point.y = player->getY();
    		if( (*it)->outline->point_inside(point))
    			(*it)->setSpawnPoint();
    But its rather uneffective to check with 4-6 Collision points myself when the collide function would be so much better.

    Error Code is the same as before:
    error C2664: 'CL_CollisionOutline::collide' : cannot convert parameter 1 from 'CL_CollisionOutline *' to 'const CL_CollisionOutline &'
    1> Reason: cannot convert from 'CL_CollisionOutline *' to 'const CL_CollisionOutline'
    I tried every combination of dereferencing but I cant get it to work

    Help would be very appreciated, thanks in advance!

  5. #5
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    if( (*it)->outline->collide( *( player->outline ) ))

    Should work (Adding "*( ... )")

    (I have not tried it)

    I have never used collisions before and I don't know the API, but maybe the API should accept pointers as well as references?

  6. #6

    Default

    thank you, everything works now !

Similar Threads

  1. Patch : load method for CL_CollisionOutline
    By sandelz in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 05-27-2009, 06:35 PM
  2. Question about CL_CollisionOutline
    By n-palmer in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 09-20-2006, 02:38 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •