iMiniB3D - problem with child collisions and crash

BlitzMax Forums/MiniB3D Module/iMiniB3D - problem with child collisions and crash

ima747(Posted 2009) [#1]
What's supposed to happen: When you touch the screen the 2 boxes will slide foward. When the box on the right (in front of, and child of box on left) reaches the wall it should stop and the box on the left should continue forward until it reaches the wall as well.

What happens: the box on the right pops through the wall as soon as any part of it touches the wall.

Other problems:
1) If you change the move code to move box2 instead of box1 but leave the parenting the same box2 will slide left VERY fast when it touches the wall rather than stopping. If you remove the parenting this does not occur.

2) the commented out EntityColor lines crash when trying to set the brush color. Maybe no brush is set?

3) Global::ClearWorld(); in the end function crashes from something within Global::root_ent->FreeEntity(); maybe the root_ent is not being created?

compiling for 3.0 simulator.

/*
 *  game.h
 *  iminib3d
 *
 *  Created by Simon Harrison.
 *  Copyright Si Design. All rights reserved.
 *
 */

#ifndef GAME_H
#define GAME_H

#include "iminib3d.h"

class Game{

public:
	
	Camera* viewCamera;
	
	Light* light;
	
	Mesh* worldBox;
	Mesh* box1;
	Mesh* box2;

	Game(){

	}
	
	void Init();
	void Run();
	void End();

};

#endif


/*
 *  game.mm
 *  iminib3d
 *
 *  Created by Simon Harrison.
 *  Copyright Si Design. All rights reserved.
 *
 */

#include "game.h"

void Game::Init(){

	Global::Graphics();
	
	viewCamera = Camera::CreateCamera();
	viewCamera->PositionEntity(0, 4, -4);
	viewCamera->RotateEntity(15.0,0.0,90.0);
	viewCamera->CameraViewport(0,0,320,480);
	viewCamera->CameraZoom(1.5);
		
	light=Light::CreateLight();
	light->RotateEntity(30.0, 30.0, 0.0);
	light->LightColor(200, 200, 200);
	
	worldBox = Mesh::CreateCube();
	worldBox->ScaleMesh(10, 10, 10);
	worldBox->FlipMesh();
	worldBox->EntityType(1);
	
	box1 = Mesh::CreateCube();
	box1->PositionEntity(-2, 0, 0);
	box1->EntityType(2);
	//box2->EntityColor(0, 255, 0, 0);
	
	box2 = Mesh::CreateCube(box1);
	box2->PositionEntity(3, 0, 2);
	box2->EntityType(2);
	//box2->EntityColor(255, 0, 0, 0);
	
	Global::Collisions(2,1,2,2);

}

void Game::Run(){
	if(Touch::TouchesDown()) {
		box1->MoveEntity(0, 0, 0.05);
	}
	
	Global::UpdateWorld();
	Global::RenderWorld();
	
}

void Game::End(){
	viewCamera->FreeEntity();
	light->FreeEntity();
	worldBox->FreeEntity();
	box1->FreeEntity();
	box2->FreeEntity();
	
	Global::ClearWorld();

}



ima747(Posted 2009) [#2]
entity color seems to work in other circumstances for me, so I'm not quite sure where that brush problem was being triggered, perhaps related to the parenting problem as where I'm currently using it and it's working there are no parents...