weimingtom / angel-engine

Automatically exported from code.google.com/p/angel-engine
0 stars 0 forks source link

game crash after using SetLayer and switching screens #73

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.make 2 screens
2.place multiple physicsactor in screen1 (maybe the other screen need some 
actors too, in order reproduce the problem)
3.within the actor's update method set the actors layer with 
SetLayer(-MathUtil::WorldUnitsToPixels(GetPosition().Y-(GetSize().Y/2))+MathUtil
::WorldUnitsToPixels(MathUtil::GetWorldDimensions().Y));
OR set the layer twice within the Update function
4.switch screens back and forth a couple times until the game crashes

Do you have any example code that reproduces the problem? If so, put it
here.

//some mob walking around the screen
void MobActor::Update(float 
dt){    SetLayer(-MathUtil::WorldUnitsToPixels(GetPosition().Y-(GetSize().Y/2))+Mat
hUtil::WorldUnitsToPixels(MathUtil::GetWorldDimensions().Y));
//Do some movement
PhysicsActor::Update(dt);
}

What is the expected behavior? What do you see instead?
clean switch of screens
instead: crash...Microsoft C++ exception: std::__non_rtti_object at memory 
location 0x00something..

What version of Angel are you using? On what operating system? Is it
a downloaded distribution or from Mercurial?
angel-3.0.1
win 7, MSVC++ 2010
downloaded

Please provide any additional information below.
i have multiple physicsactor on screen and want the lowest one to be in a 
higher layer than the others...works fine
but as soon as I switch to another screen the game crashes
i tracked it down to:
the screen with the actors stops, gets deleted
when trying to call ProcessDeferredLayerChanges(); from World::Simulate
it trys to access layers or renderable which doesnt exist anymore...
dynamic_cast leads to the exception (access violation)

Original issue reported on code.google.com by maliusa...@gmail.com on 6 Jan 2013 at 3:37

GoogleCodeExporter commented 8 years ago
It sounds like you're trying to make your actual game out of IntroGame? It's 
intended for instructional purposes only, and each example is only guaranteed 
to work within its specific screen. You should build your game in the mostly 
empty ClientGame project, since it doesn't contain all the extra machinery for 
demo purposes that IntroGame does. 

Original comment by lieseg...@gmail.com on 6 Jan 2013 at 8:01

GoogleCodeExporter commented 8 years ago
I'm working in the ClientGame project
I just copied the screen concept

Original comment by maliusa...@gmail.com on 7 Jan 2013 at 2:20