add physics sprite

Jan 21, 2013 at 2:44 AM
Edited Jan 21, 2013 at 2:47 AM

private

void UserMainControl_Loaded(object sender, RoutedEventArgs e)

{

 

for (int i = 1; i <= 4; i++)

{

 

UcBlock newBlock = new UcBlock ();

 

List<PhysicsSprite> newBrick = cnvGame.AddPhysicsUserControl(newBlock, 540, 200+ (i * 50),1);

}

UcBall newBall = new UcBall (); }

cnvGame.AddPhysicsUserControl(newBall, 640, 200, 1);

 

Hi, I'm trying to create some bricks and a ball when the cnvGame is loaded. But currently the ball is a user control, and I don't want it to be controllable by the user. How can I add a normal physics sprite to drop from the same place after the bricks are loaded?

 

Coordinator
Jan 21, 2013 at 3:36 PM

I'm sorry I don't understand the question. It looks like you are using AddPhysicsUserControl, which is used to dynamically add user controls at runtime to the physics simulation - which is correct.

If you need a full example of dynamically adding objects, please see the "Advanced" demo in the download.

Jan 23, 2013 at 8:14 AM

Sorry my question wasn't clear. The trouble I'm facing is that all physics objects within the game are mouse-pickable. I would like some objects to be mouse-pickable, but others not. The reason is that I'm trying to create a game where all physics objects react to gravity, but only a few of them can be selected or manipulated by the user.

I've tried removing MousePickEnabled from the canvas and adding it onto individual items, but unfortunately it failed to run. When MousePickEnabled is TRUE for the canvas and I choose MousePickEnabled = FALSE on the individual physics object, nothing changes and the object remains selectable by the mouse.

I would like to understand how to create some items that are selectable by the user (MousePickEnabled) and some that are not selectable by the user within the same canvas.

Perhaps I'm missing something but in the "advanced" demo all objects appeared to remain pickable.