none
Questions on 2DBOX Extension RRS feed

  • Question

  • Hi Everyone !

    I downloaded Litdev's 2DBOX Extension,and try to get the Velocity and Postion of a moving object.

    http://social.msdn.microsoft.com/Forums/en-US/smallbasic/thread/fb47064e-0d28-4fca-90ca-0cdd5dee3d64 (Extension to download)

    But the return value of getVelocity and getPosition are an array with 2 values(X and Y)

    Example :GetVelocity as an array shows on textbox

    a = Controls.AddTextBox(100,100)
    ball = Shapes.AddEllipse(40,40)
    LDPhysics.AddMovingShape(ball,1,1,1)

    While("true")


    LDPhysics.DoTimestep()
    Vel = LDPhysics.GetVelocity(ball)
    Controls.SetTextBoxText(a,Vel)
    Program.Delay(10)

    EndWhile

    '//////////////////////////////////////////////////////////////////////////////

     

    And I want the X velocity in seperate,

    so i tried the array api of SmallBasic to get array's value in seperate:

    a = Controls.AddTextBox(100,100)
    ball = Shapes.AddEllipse(40,40)
    LDPhysics.AddMovingShape(ball,1,1,1)

    While("true")


    LDPhysics.DoTimestep()
    Vel = LDPhysics.GetVelocity(ball)

    VelX = array.getvalue(Vel,1)
    Controls.SetTextBoxText(a,VelX)
    Program.Delay(10)

    EndWhile

    '////////////////////////////////////////////////////

    But the textbox shows nothing.

    ///My Question1 : Is there any way to get seperate value of Velocity or Position array?///

     

    ///My Question 2 (Have nothing to do with the above):

    The Panview only work for the objects added into the engine,but there only 2 ways to add :Addfixed or AddMoving,which both are doing with physics.

    I want to add one that isn't effected by the engine,but go with the panview settings.///

    Could any help me out? Thanks !!


    • Edited by Zaoeyo Tuesday, January 17, 2012 8:24 AM
    Tuesday, January 17, 2012 8:24 AM

Answers

  • 1] To get just the Y velocity in the textbox, try:

    Controls.SetTextBoxText(a,Vel[2])

    The Array.GetValue is some-what depreciated and the following doesn't work either.  Easier to use the square bracket notation.  The reason is to do with internal structures for arrays that changed when we went from SetArray and GetArray to the square bracket notation - they don't mix well.

     

    Test[1] = 1
    TextWindow.WriteLine(Array.GetValue(Test,1))


    2] If you have an object with no physics interaction and don't add it to the engine (like a cloud) and you pan, then you have to move the shape yourself (e.g. when you pan right, move it left etc).  I will consider if it is possible to add non-interacting shapes to the engine so they are moved automatically, but take no part in the physics collisions.

    EDIT

    LDPhysics.AddInactiveShape(shapeName) method added which does nothing except move the shape object with the LDPhysics.PanView method.

    • Edited by litdevModerator Tuesday, January 17, 2012 7:12 PM
    • Marked as answer by Zaoeyo Wednesday, January 18, 2012 12:45 PM
    Tuesday, January 17, 2012 12:27 PM
    Moderator

All replies

  • 1] To get just the Y velocity in the textbox, try:

    Controls.SetTextBoxText(a,Vel[2])

    The Array.GetValue is some-what depreciated and the following doesn't work either.  Easier to use the square bracket notation.  The reason is to do with internal structures for arrays that changed when we went from SetArray and GetArray to the square bracket notation - they don't mix well.

     

    Test[1] = 1
    TextWindow.WriteLine(Array.GetValue(Test,1))


    2] If you have an object with no physics interaction and don't add it to the engine (like a cloud) and you pan, then you have to move the shape yourself (e.g. when you pan right, move it left etc).  I will consider if it is possible to add non-interacting shapes to the engine so they are moved automatically, but take no part in the physics collisions.

    EDIT

    LDPhysics.AddInactiveShape(shapeName) method added which does nothing except move the shape object with the LDPhysics.PanView method.

    • Edited by litdevModerator Tuesday, January 17, 2012 7:12 PM
    • Marked as answer by Zaoeyo Wednesday, January 18, 2012 12:45 PM
    Tuesday, January 17, 2012 12:27 PM
    Moderator
  • Hi litdev,

    Great Thanks for helping !!!

    Looking forward to updates on 2DBOX Extension !

    Best Regards

    Zaoeyo

     

    Wednesday, January 18, 2012 12:59 PM
  • The mods were uploaded in the same place.
    Wednesday, January 18, 2012 1:48 PM
    Moderator