I’m trying to develop a game that allows a player to drag playing cards from their hand to a location on an open table
Cards can only be dragged and dropped to certain positions adjacent to a card that was played prior. The valid locations are either vertical or horizontal from the last played card, unless it’s the first card and it can be dropped anywhere. I’d like the adjacent locations that are valid for dropping a card to be highlighted in green when it’s the user’s turn as illustrated below:
Would I need to use the CustomPainter class to handle this situation? If so, should I make the entire Custom Painter area a drop target and have it update appropriately when dragging?
Looking for ideas/input. Thanks.
Related
I am migrating game from windows phone to flutter card game. I cannot find the way how to keep the card on the top after dragging.
Stack order is too complex and problematic for such simple action and would involve 4 player active, not active cards, cards on the table, combination sets re-arrangement :( In Windows phone there was a Rectangle with ZIndex which i could set to any rectangle on the screen.
I am missing something similar in flutter. I cannot believe that stack order is only way to solve this because it would make any game development impossible.
I am not using any game engine (maybe thats a problem) but i feel like i do not need it because it is not game-loop based game it is event based - click, drag etc.
Do you know any solution how i can achieve that?
There are 2 options -
1. Stack
Update the position of its children by mutating the List and calling setState or use Positioned.
2. Material
The Material widget has a property named elevation. Set it's value dynamically to achieve the effect
I am building a chess board component, in which we should move the pieces by a simple Drag And Drop. In order to ease the drag and drop, I also try to draw a feedback which is a "cross of cells" centered around the pointer.
So, I am trying this way :
I draw a container that starts at the pointer location
Inside that container, I draw the entire cross, also drawing the dragged piece at the center of this container
So, I need a way to shift that feedback half to the left and to the top. That is, I need the feedback to be positionned to left and to the top of the pointer location.
Is that possible ?
I've tried playing with feedback and dragAnchor properties of Draggable, but I did not achieve.
I have developed scratch card effect.I am stuck at logic of how can I know object got visible which is behind the scratch card image? So that I can show reward screen.
PS: with modifications in this link I able to work this scratch card effect in uGUI.
There are many ways you could go about this. Assuming you know the dimensions of the red "target image" that the user is trying to uncover, you could take a fixed number of samples from the area that the target is under. Once, say, 80% of those samples are transparent (i.e. the target is visible at those positions), you can consider the object visible and show the reward screen.
You can use GetPixel to get the individual samples from the scratch texture.
In gamesalad framework I am creating a game in which I have an actor which only moves on x-axis on touch is pressed. But when I move it to x-axis the actor goes away out of the range of the screen. Let me clarify that I am new to gamesalad framework.
plz help to solve the problem.
I'm reading this in two different ways:
1 - when you press your touch controls the actor disappears from the screen
2 - when you press the touch control the actor moves along the x-axis and out of the screen
For the sake of argument I'm going to assume that we're talking about number two.
What you'll need to do is restrict the actors movement to the boundaries of the current screen. You can do this is two ways with Gamesalad
1 - create an invisible barrier for your actor to collide against
2 - use a behaviour to prevent your actor from going beyond the screen boundary
I'll explain both:
1, Invisible barriers
What you'll do is create a new actor, and set it to collide with the actor that your controlling. You'll create a few instances of this actor to create a walled area for your actor. Although this works, it's a little cludgy and using additional actors in a scene take a little performance away from your application.
2, using a behaviour
In my opinion the better way is to use the given behaviours in Gamesalad itself.
To stop the player actor from moving off screen you can use a combination of Rules and the Constrain Attribute behaviour to achieve this.
The first thing to know is your screen size; for an iPad I believe it's 1074 along the x-axis.
So to stop the actor moving off either side of the screen you'll need to do the following:
Open up the player actor
the click on the "Create Rule" button on the top right.
A new rule window will appear, but default the first dropdown will say "Actor receives event" change this to "Attribute".
Next select the attribute to use the rule against, since we're interested in the x-axis we'll want to query that player attribute which will be:
(also known as self) > Position > X
Select the greater than symbol (">") and then enter the maximum width of the screen minus whatever border value you want, so I'll use 1014 (1024 - 10).
Find and drag the Constrain Attribute behaviour into your rule a set the actors X position to 1014.
This will stop the actor from going beyond one side of the screen, now copy the rule and amend the settings to that if the actor goes less than, say 10, it will constrain the actors X position to 10.
I'd post an image, but alas my Karma isn't large enough right now! Hence the large explanation!
Hope this is what you're looking for!
It is way easier than that.
In top of the Gamesalad Creator there is a play button, which you probably know, displays your progress. To the left of this button there is a button that looks like a little video camera, it changes the camera settings. So what you first have to do is click the camera button, then the rectangular camera screen will show itself as marked. In the center of each of the sides of the highlighted rectangular which is the camera screen, sits 1 little grey rectangular. Each of these needs to be pulled to the center of the camera view so that you get a little grey "cross" in the center and from the center to the boarder there will now be this highlighted color.
Second and last step is easy, just go under your character and in (type or drag in a behavior block) you type control camera... or drag the control camera block, which as by the type box is statet possible.
Since Gamesalad only can have one camera at a time, and you character is the only one with the control camera option applied it will follow him and only him. Wherever your character starts on the screen, the camera will follow it when it passes through the center of the screen. You may know this from Super Mario Bros. Where you start of a little to the left and walk right and the second Mario enters the center of the screen, the camera follows him from then on.
Hope this helps... :
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