Skip to main content
Inspiring
June 27, 2023
Question

Move object to specific position

  • June 27, 2023
  • 3 replies
  • 1211 views

I was thinking this would be an in built function but I cant find it.
Maybee it needs to be scripted. I would like to move an object to a certain x/y position when pressing a button. I can not use the motion function. 

I have to objects that when pressing a button I need them to go to a position and at the same time set two variables to 0. The variables are the easy part 🙂

    This topic has been closed for replies.

    3 replies

    Widget King
    Inspiring
    July 11, 2023

    CpExtra does have command variables which allow you to do so. Such as:

    They work best in standard Captivate projects. It's very difficult to position something reliably in a responsive project.

    Lilybiri
    Legend
    July 11, 2023

    Thanks Tristan, forgot to mention this. It has been a confusing thread.

    Stagprime2687219
    Legend
    June 27, 2023

    The tricky part about this is that positioning is relative in Captivate for most things like this. So basically the start position of every object will be 0,0 and you end up calculating the number of pixels to move the item from there

    Suppose I have a box inititally located at position 50,50 - this is 0,0 for that item

    If I wanted to move it to 0,0 for the stage - I need to move it using the top and left parameters

    $("#boxc").animate({left:-50});

    $("#boxc").animate({top:-50});

    With this setup - you would see two discrete movements. This would slide left first and then up. If you wanted a more direct and diagonal movement you could combine the above.

    $("#boxc").animate({left:-50,top:-50});

    From the 0,0 position of the stage - if I now wish to move the box to 100,100 on the stage

    $("#boxc").animate({left:50});

    $("#boxc").animate({top:50});

    Notice that I have to consider the 0,0 position of the item and go right and down from there - rather than the current position.

    I would suggest making a blank slide and experimenting with this a little before adding it to your current project.

    Let me know if you have any questions about this 

    Inspiring
    June 29, 2023

    Thank you for reaching out. And to lilybiri. Seems like there is no easy way to get one object to move to another place without using a from of transition.


    Lilybiri
    Legend
    June 29, 2023

    Did you use the alternative by using two multistate objects. Even @Stagprime2687219 agreed that this was the easiest way to avoid any movement. Sorry that I was confused by the verb 'move' which to me is pointing to a movement. I am not a native English speaker, and am used to UK English.

    Lilybiri
    Legend
    June 27, 2023

    Why cannot you use a motion effect? You need to create a custom motion effect (and use guides for precise positioning) and use an advanced action where you combine the value assigments of the variables with the application of the custom effect. More information in:

    https://blog.lilybiri.com/how-to-use-custom-effect-in-actions

     

    Inspiring
    June 27, 2023

    I am using that But I need to position the object at its original position and cant use the custom motion for that

    Lilybiri
    Legend
    June 27, 2023

    What do you mean, please can you explain more in detail. Maybe show screenshots. I suspect you are on non-responsive project because coordinates don't make sense for a responsive project.

    Using guides allows you to position them in an exact x and y location. Or edit the XML file.

    You can create custom effects in two directions using the same guides. Have a look at this example:

    https://blog.lilybiri.com/sliding-menu