Table of Contents

 
TestBatchCollision
 

Purpose

Compares a bunch of sprites at once

 

Protoype

hit_test CSpriteMngr::TestBatchCollision (batch bc_group1, batch bc_group2, int i_flag)
 

Parameters

group1 the first group of sprite IDs
group2 the second group of sprite IDs
flag the compare method
 

Description

This function tests a bunch of sprites against each other in one of two ways. The first way uses the flag TEST_PARALLEL and compares each sprite object to the same object in the other batch. So the first sprite object in batch1 would be compared to the first object in batch2, the second in batch1 to the second in batch2, etc. The second compare method is much more processor-intensive as it compares each object in batch1 to each object in batch2. This compare uses the flag TEST_CROSS. The function then returns a list of the boolean test values. Depending on the test method, you will have to sort through the results in a different manner. For TEST_PARALLEL you can iterate straight through the list but for TEST_CROSS you will have to use nested for loops to extract the proper values.

NOTE: The TEST_PARELLEL method obviously needs balanced batches (batches of equal size) to work properly. If the function detects an unbalanced batch, it will warn you in the log but do nothing to stop the operation

 

Use

CSpriteMngr sprite;
// build batch1
batch bc_group1;
bc_group1.push_back("my_sprite1");
bc_group1.push_back("my_sprite2");
bc_group1.push_back("my_sprite3");
// build batch2
batch bc_group2;
bc_group2.push_back("my_sprite1");
bc_group2.push_back("my_sprite2");
bc_group2.push_back("my_sprite3");
// compare them
hit_test ht_results = sprite.TestBatchCollision(bc_group1, bc_group2, TEST_PARALLEL);
 

Prev: ShowSprite