justinmind-logo
 
Upvote 1

on tap move object

Known sherman 6 years ago

Hi,

I have a 3x3 grid (A1, A2, A3, B1, B2, B3, C1, C2, C3) where there is a shape in the middle of the grid (B2). When I tap the shape, it moves to A3. Is it possible for the same shape at A3 to move to A1 on tap, and again from A1 to C1 on tap?

Replies (3)
photo
1

hello any body?

photo
1

Hi Sherman,

Apologies for the late reply! Do you have an example of what you're trying to accomplish?

Best,

Danielle

photo
1

Hi Danielle


I attach a sample file for your visualization.

This is accomplished using 5 shapes by hiding the first + showing the second after the move, hiding the second + showing the third after another move... but what I want is moving only the initial shape.

photo
photo
1

You can move the shape to wherever you like. How simple that is depends upon whether or not there is logic to where it is supposed to move to based upon its current location and how complicated that logic is. The most basic approach would be to implement the movement logic based upon shape location using "when" conditions for the move actions.

So, for example, if your grid is 90 x 90 and your shape is 30 x 30, you could create the following move expressions:

On Tap - When (shape:posX.fixed = 30 AND shape.posY.fixed = 30) -> Move shape left:fixed:60 top:fixed:60

Else When (shape:posX.fixed = 60 AND shape.posY.fixed = 0) -> Move shape left:fixed:0 top:fixed:0

Else When (shape:posX.fixed = 0 AND shape.posY.fixed = 0) -> Move shape left:fixed:0 top:fixed:60

However, the larger the number of squares in your grid and the larger the number of possible moves, the more unwieldy this when/else will become. If there is a more definable logic to the shape movement that can be reduced to an algorithm, then you may be able to implement it with a relatively simple when/else expression, possibly made even simpler utilizing relative X and Y positions as opposed to fixed X and Y positions.

photo
2

Hi eggroll, thanks for your suggestion!

I have tried your suggestion and it is working perfectly like how I wanted to!


Thanks alot!

photo
2

Great! Glad to hear it.

Upon re-reading my response, one correction I should make is to the very last line where I write "If there is a more definable logic to the shape movement that can be reduced to an algorithm, then you may be able to implement it with a relatively simple when/else expression, possibly made even simpler utilizing relative X and Y positions as opposed to fixed X and Y positions."

If your shape movement is reducible to an algorithm, in all likelihood it will be aided or simplified not by using relative X and Y positions as opposed to fixed positions, but rather using the "Offset" option instead of specific positions (fixed or relative) in determining the shape's next position, since what would likely make an algorithm more useful is its ability to describe a pattern of movement not reliant on having the specific position of the shape at any one time. This, of course, would depend upon the algorithm.

Hope that makes sense.

photo
Leave a Comment
 
Attach a file