I know it seems like it's a fairly easy to do, but i can't seem to figure it out and i've researched a lot of places but really what i want it's no where.
i'm creating a puzzle game and the images are moved around using UIGestureRecognizers but let's say if the puzzle piece does not fit into the right location, i want it to move to it's original position or previous position where i got it from. Can someone please shed some light on this on ho to do this? Thanks
The easiest thing to do would be to add a property to your view controller to store the CGPoint of the puzzle piece before you move it. Check for UIGestureRecognizerStateBegan in the state of the recogniser(which i think you must already be doing in order to start moving the puzzle piece) and update the property with the touch location from the view.
Related
I am using r82.
I have a mesh with multiple materials. I can change their opacity just fine, but how they are rendered is what I would call "splotchy". I have been using ThreeJs for a while, and EDIT: was able to get the transparency working in a past version (r67) with the same model in a significantly more consistent way. So I was wondering if there is something that now I need to set that I didn't need to set before or if I am just overlooking something. Upon revisiting my older code and testing it again, I found that the same transparency issues were present. It was simply a matter of there not being as obvious "splotches" (and not testing enough, I'm sure). Here is a screenshot.
Here are a few more pictures I took that highlight the issue a bit better. I have the outside wall in a light grey and the floors a dark grey in the model and can toggle the outside walls to be visible or not. In these pictures I have one face of the outside wall purple and a face of the floor in the room on the other side of the wall green.
Based on the angle of the camera, it makes part of the green floor face invisible even though there is only one face between the camera and it.
The materials are all double sided already and there is no sign of this until the transparency is on. I found a similar question that suggested changing the mesh.setFaceCulling (or something similar) but that seemed to be from an older version and wasn't in r82.
Thanks for any help in advance!
EDIT:
I started looking into the old version of threeJS and the current version's source code to see what is done differently regarding transparency. I found transparentObjects, which is an array of the objects (I believe faces) that are going to be rendered and are in sorted based on "reversePainterSortStable". There is another list of objects (I believe for the materials objects, maybe?) called opaqueObjects that uses "painterSortStable". So to see if changing the sort order would change the outcome of how things are looking when transparent I changed it so that transparentObjects got sorted by "painterSortStable" and it did change how things showed up significantly (granted it didn't fix my problem since it just removed some problem spots and created new ones).
So the short version, it looks like it is an issue with the renderOrder of the faces.
That being said, I tried finding how the r67 version of the code handled the "renderOrder" of the faces since it wasn't something that (to my knowledge) could be set in that version and just did it automatically. But I have had no such luck tracking down how it was done as of yet.
So I see two possibilities. 1) find out how the past version correctly did transparency (at least for my purposes) and change the logic in the current version to use that. Or 2) find how to properly set the renderOrder of the faces based on the camera position in the scene. Will look into the second option first, but figured it would be good to document this for others looking to help answer or that have a similar problem.
EDIT 2:
So digging through the source code for threeJs and noticed something about the transparentObjects array I mentioned in the previous edit. The first, that I cannot for the life of me figure out how it gets populated since it doesn't seem like it is added to anywhere in the code. The second is that I think it is being populated with duplicates of the entire building object/mesh (see screenshot below).
The z indexes all seem to be the same. as well as the ids and the objects are all of type "mesh" (of the ones I looked through, granted, since there are a few thousand). So I was going to figure out why its adding what is being added to the array, but that is when I stumbled across the issue of not finding where in the code that the transparentObjects array actually get populated.
EDIT 3:
WestLangley, I tried setting the depth test for the outer wall material to false and got this. Like I said in my response comment, even if it did work it wouldn't fix the issues experienced with the camera inside the building, but wanted to follow up none the less (see snapshot below).
Ok, so I've been working on a game with some friends for a school project. We have used SFML.
I've been working lately on the camera and a tile implementations system and now I need them to work together.
The camera works like this:
I have two different sf::View, one for the game world and one for the hud. The one for the game world follows the player in the x-axis.
The tile system works in a way where it reads in a txt file and draw sprites based on the information from the txt file.
As it is now I always draw all the tiles, even if it's outside of the cameras view. Not good. I need a way to check if the tiles are outside of the cameras view before I draw them. How do I do this?
I did find this:
Get X and Y offset of sf::View
but I can't really wrap my head around how to make this info work in my game.
Any help would be really appreciated! :)
Mvh Elis
Managed to figure it out after finding this:
http://fr.sfml-dev.org/forums/index.php?topic=10590.0
I know it's something with texture.needsUpdate() while rendering but I don't have a clue how to actually implement it. Maybe someone knows a link where I can see a working example or post some piece of code? Cheers.
An excellent question; I created some sample code to do exactly this -- using a spritesheet to do some 2D animation on a plane and on a cube, which requires regular updates. Here is a link to a documented example, that in particular contains a function to do exactly what you need.
http://stemkoski.github.com/Three.js/Texture-Animation.html
Hope it helps!
question is....
i need to handle tap gesture.
Now, i have a lot of paths builded by CGPath (each path has an ID), and by CGContextAddPath i create and fill my planimetry. Whether i tap on a path, i wish that right ID is shown.
So, i'm using CGPathContainsPoint in touchbegin to do this but, if i scale up or down my planimetry by CGAffineTransform, CGPathContainsPoint method returns wrong information (FALSE) also if i touch on a (scaled) path.
How can i fix it ?!
I tried by adding CGAffineTransform element as second argument of CGPathContainsPoint method but point touched isn't scaled too, so, nothing happens (instead, the same problem with translation is fixed by this same way!).
Here you can find the CODE semplified
Sorry for my english ( i'm italian ) :P
Thx in advance
OK! I found the problem !!!
I have to apply the inverse function!!
If i scale by 10, i have to scale the point by 1 / 10.
For translation if i drag by 10, i have to drag back by -10 (for rotating the same i think).
I have a requirement where in I have to move four objects on an elliptical path.
Am using Expression Blend and was able to create a motion path quite very easily and place objects over it. It was also cool creating storyboards and keyframes.
The problem came when i wanted all the objects to move at once, their starting points being different. I mean I want the sarting point of each object to be different.
I have searched for answers but could find people ending up in creating their own custom paths through code behind.
Is there a way that we could achieve this through Expression Blend?
Thanks in advance,
Sri
What are you trying to do, exactly? If you are creating a Storyboard, why not just give each object a different starting location? If you are trying to create a Carousel or something like that, check out PathListBox. If neither of these are helpful, post some more specifics.