Im making an iPad app that will have some objects on the screen in a menu area. I want the user to be able to touch down and drag from one of these objects to place a new copy of that object on the view.
To further explain, say I have a checkers chip on the side of the UIView in the "game piece" / menu area. I want the user to touch down and drag from that checkers piece to drag a new checker piece onto the game board. I dont want the original checker to move, its just a place holder, but I want to create a new object that is dragged from the first checker.
I see a couple of ways to do that however I cant figure out how to do it without the user picking up their finger to reselect the new game piece. I want the new piece to be drag able immediately after touching the first place holder object.
Any ideas? Please and thank you for the assistance.
I've solved this before by creating a copy of the UIView that I wish to move, then using the UIResponder API (touchesBegan, etc.) to move the new copy in its superview based on the drag gesture translation, thereby leaving the original "menu" view in situ. Does this make sense?
When you create the moveable copy, you can set its alpha or create a border or some other visual confection to indicate the provisional nature of the drag object.
Related
I have a question regarding Unity and mrtk. I need to create an object, which can be deleted via button push. This button should be attached to the object. Now there is the app bar which can be attached to the object and which is very convenient because the buttons are only displayed on the side of the object you currently look at. However the app bar does not seem to work properly with the new bounding box and after deactivating the adjust button on it. So my question basically is, how do i make a button which is attached to the object, hovers on it and is only displayed on the side of the object i am currently looking at? The script of the app bar is very poorly commented, so i cannot figure out which part is responsible for making the button appear on the correct side and correspondingly how to write a script displaying the delete button only on the correct side (following the direction i am currently looking at).
To solve this problem you need a free Canvas that attaches to your object. This Canvas should be adjusted to the dimensions of the object and always look at the camera. To do this, first create a canvas and set RenderMode to World Space, Remember that you have entered the Event camera reference.:
After completing the canvas, make a button like the one below and place it in the body. In this section, adjust the dimensions so that you want to appear in near of your main object.
Finally, I suggest using Look At Constraint to match the canvas and the view to the camera. Insert the camera as source and fix Constraint settings it as shown below.
Example Result
I am doing a game with Unity3D in which there are 2 players using the same mobile device in turns to play.
I am adding a Settings scene in which each players enters his/her name and can select an Emojicon to use as an avatar in the game.
I have already imported the png file in to my Resources folder and cut it to 80 sprites using the sprite editor called emojicons1_0 to emojicons1_79.
What I need is to enable the players to change the default emojicon in the Settings if they touch the existing emojicon or a button "Change" beside it.
I was thinking of showing a scroll list from the asset called Gamestrap UI and display an array of 4 x 20 emojicons, and they can select there the desired emojicon. I don't know how to do this, and I appreciate any help. I am open to other suggestions of course.
Thanks in advance for any help.
if you are using uGui, there is a number of ways to do it. I would simply create a view prefab, which will composed of scroll list with grid layout inside. It will have a script attach, which will initialise the view by loading textures/sprites and set it to image component of an instantiated button prefab, which represents one icon to select. Then view has callback and on click simply call it with selected image.
Here is references:
https://unity3d.com/learn/tutorials/modules/beginner/ui/ui-scroll-rect
https://docs.unity3d.com/ScriptReference/UI.GridLayoutGroup.html
How are objects made draggable on iphone?
How is an item/object moved by the user. e.g. apps can be moved on the homescreen and they icons follow the users finger.
How can e.g. a tableview cell contents be moved if the user holds down on it and then moves their finger?
What controls the movement of these objects to follow a users finger?
There is no built-in support of dragging controls and you need to implement one. My answer to another question is related and might help.
Dragging values onto labels
hi i am new to iphone. what i need is i want to display an image for example balloon. when ever i click the button the balloon automatically start moveing up vertically from bottom of the simulator to top of the simulator.While it reaches top of the simulator automatically it moves towards down.How can i done this.please post any relevant code or link.Thank you in Advance.
Have a look at this example from Apple you just need to recognize the first touch on the balloon and then make it move wherever you want (by using an animation or manually redrawing the UIImageView representing the balloon each time using a NSTimer)
I tried to find an easy solution for the following.
I have a main view which holds a tile. I want to drag and drop it over a UITableView. I could program the pick and drag already with UIGestureRecognizer.
Now my problem is how can I detect within the table view that there is an item going to be dragged above it. For instance I want to highlight the given row when the tile is moved above it.
I tried to add the touchesMoved/Began/Ended events to the viewCell. They does not get fires when I am dragging the tile over it (in other words the tile is hiding a portion of the viewCell under my finger). They get fired when there is no tile dragged above.
Is there an effective hittest method for that?
Thanks.
There are a whole bunch of UI issues here that should be addressed.
In general, Drag and drop on the iPhone is a BAD idea. It's very hard to do, and getting feedback is going to be problematic, because your finger will be obstructing the drag operation
using the table's selected cell to indicate 'dropability' may get you rejected by the app store reviewers; it's to indicate "I've selected this cell", not "I'll drop something onto it"
That said, you'll probably want to manage all your touch events in the 'source' view, and send the table messages from there, rather than trying to juggle messages around. Once your -touchesBegan:withEvent: has been called in one view, all subsequent -touchesMoved:withEvent: and -touchesEnded:withEvent: will be sent to that view for the life-cycle of that touch; forwarding them around will confuse the heck out of everyone involved.