Box2D and the iOS runner
#1
Posted 02 March 2012 - 02:31 PM
Would this be something I am doing or is the runner on iOS not fully compatible with Box2D yet?
#2
Posted 02 March 2012 - 02:51 PM
Russell
#3
Posted 02 March 2012 - 03:20 PM
I have had a look over my code and I can't seem to see what I am doing wrong, I only have the bare minimum code for the physics to work.Must be something that you are doing as everything works at full speed here...
I only have 4 objects. obj_Controller (For the world and spawning objects), obj_Block (The falling block), obj_Ball (Same as the block just a different sprite) and obj_Floor.
//////////////////////////////
//obj_Controller Create Code
physics_create_world(rm_Room,-16,-16,480,320,16)
physics_gravity(rm_Room,0,-8)
physics_update_speed(rm_Room,1)
for(i=0;i<=480;i+=32)
{
instance_create(i,304,obj_Floor)
}
//////////////////////////////
//obj_Control Step Code
random = irandom(1)
if (random == 0)
{
instance_create(mouse_x,mouse_y,obj_Block)
}
else
{
instance_create(mouse_x,mouse_y,obj_Ball)
}
//////////////////////////////
//obj_Block Create Code
pfx = physics_create_fixture()
physics_fixture_set_box_shape(pfx,16,16)
physics_fixture_set_density(pfx,1)
physics_fixture_set_collision_group(pfx,1)
physics_bind_fixture(pfx)
//////////////////////////////
//obj_Floor Create Code
ffx = physics_create_fixture()
physics_fixture_set_box_shape(ffx,16,16)
physics_fixture_set_collision_group(ffx,1)
physics_bind_fixture(ffx)
What I don't get is that I works mint in the C++ runner.
Edited by Mayhem Games, 02 March 2012 - 03:21 PM.
#4
Posted 02 March 2012 - 03:24 PM
1) The negative values for the physics container may be an issue on the iOS? This might cause problems.
2) The floor loop might not be closing for some reason as it's in create code? Causing infinite lag due to placing forever? I'm reaching for this but the characteristic of your FPS lag says it's not enough to hardlock the game but enough to cause fps lag.
3) And mouse_x/mouse_y might be static, so even when your finger is off the screen it might still have that number. Causing overlays and lag.
4) Suggestion:
switch (irandom(1)) {
case 0:
instance_create(mouse_x, mouse_y, obj_Block);
break;
case 1:
instance_create(mouse_x, mouse_y, obj_Ball);
break;
}
I only suggest this so you don't have a variable hanging around, and I find for simple things, switch() checks are fast, neat, and clean.
*Edit* rwkay has your answer
Edited by CloudBomb, 02 March 2012 - 03:48 PM.
#5
Posted 02 March 2012 - 03:46 PM
The instances will all be getting created at 0, 0 and they will be intersecting causing the physics to go mad...
Russell
#6
Posted 02 March 2012 - 04:08 PM
Lol, I was meant to set it to global mouse release but the time of night must be getting to me.You are creating an instance every frame
I have corrected that mistake and changed my step event to the global mouse release but it still lags, I even removed that entire event and had one block spawn in the obj_Control create event instead.
Would the type of iPhone effect the proformance? I have an iPhone 4G as my test phone.
Edited by Mayhem Games, 02 March 2012 - 04:09 PM.
#7
Posted 02 March 2012 - 04:57 PM
#8
Posted 02 March 2012 - 11:12 PM
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











