Using Flash 8, and ActionScript 2, what is the max value that an _x property on a MovieClip can be? For instance, is it okay to position a movieclip at _x = 60000?
I think limitations will come from the dimensions of your clip, not as much from the position.
The limit is 2880x2880 size wise, and I there might not be one for positioning, but even if, 60000 px should work. I tried creating and empty clip, positioning it and tracing it. Something as simple as that works.
What exactly are trying to test/achieve ? This sounds a bit like a workaround, maybe it can be avoided.
To answer your question, as far as i know, you can set the ._x property of a movieclip to any value you want as long as it is within the boundaries for of a (32 bit) Integer.
Setting the property to extreme high values will effectively hide the movieclip as it will sit far outside the boundaries of the stage.
Of course setting ._visible to false is a much cleaner way to achieve the same thing.
On my system here (Intel 6300), a quick code test produced a +/- limit of 107374182 on the _x and _y properties.
I assume this may change depending on the hardware running the player.
Testing using AS2 with Flash CS3, the exact numbers for when the sign gets flipped is from 107374182.3 to -107374182.4 for both the x and y axes.
Related
I tried using the SCNFloor and Material, but it draws with limited width and length.
Is there any way I can generate an infinite grid.
Probably this could be the issue: Have you checked the zFar value of your SCNCamera? the Default is: 100m (this means everything that's more fare away is clipped by the renderer) - you might want to set it to a really high value and also disable the automaticallyAdjustZRange property (what should be the default). Hope I could help you.
I am working on a graphics application and have a number of objects with captions. To put the captions, I calculate an X, Y coordinate and call:
Canvas.TextOut(XText, YText, FCaption);
I decided to use a different mapping mode to make conversions from world space to device space simpler:
SetGraphicsMode(cnv.Handle, GM_ADVANCED);
SetMapMode(pbxMain.Canvas.Handle, MM_HIENGLISH);
and now my captions are printing upside down, but still left to right.
Any thoughts on how to remedy that?
One approach I had considered was setting the map mode back to the default for outputting text, which would require some conversions to get X, Y in the different mode. Is that a reasonable tactic? Is it "correct" to change map mode during paint routines...?
Although the y axis reversed when you set MM_HIENGLISH map mode, assuming a default previous value of MM_TEXT, it doesn't cause text to be output upside-down - it just effects where it's output.
You might want to check if you're calling SetWorldTransform which is a probable cause for the problem you observe - a faulty transformation. A negative value in eM22 of the transformation structure parameter causes a reflection in the y axis.
Regarding the last part, I don't see any problem switching map modes during a single drawing task, apart from it might complicate maintaining the code.
The only doc I can find doesn't say much:
A CIVector object whose attribute type is CIAttributeTypePosition and
whose display name is Center.
I did some experiment. I can see it shift some "center". But I want to know what exactly it controls in the underlining pixelation algorithm so that I can use it in a knowledgeable way instead of blindly fumbling.
I think it shifts where the initial sampling point is taken, so that combined with the scale parameter will adjust which pixels are pulled out for the pixelate.
You can try it out in QuartzComposer (or even Acorn (an app written by myself)) and futz around with the parameters to get a good idea as to what it does.
Note: I have tried this answer: Gap between SKSpriteNodes in SpriteKit collision detection
I am getting gaps in between my SKSpriteNodes, after 5 minutes of letting my game run. Here is my code to make the node:
let tileNode = SKSpriteNode(imageNamed: "world1Tile\(tileNumber).png")
tileNode.position.x = x
tileNode.position.y = y
tileNode.size.width = 128
tileNode.size.height = 128
tileNode.zPosition = 10
tileNode.physicsBody = SKPhysicsBody(rectangleOf: tileNode.size)
tileNode.physicsBody!.isDynamic = false
tileNode.physicsBody!.restitution = 0
tileNode.physicsBody!.allowsRotation = false
tileNode.name = "Tile"
row.append(tileNode)
When I remove the physics body, it is running fine. Here is are some images to show you what I mean:
This image has a physics body, and was taken after immediately after running the app.
This image was taken 5 minutes after running the app.
Why is this happening? I assume it has something to do with the physics body, because my app looks exactly like the first picture, even an hour after running the app if there is no physics body. What physics body property should I change to stop this from happening? Any help would be appreciated.
I had a similar issue not too long ago, where gaps were appearing between nodes that were tiled (although I didn't use physics). Based on this answer, I found that if you want perfect alignment between nodes, it is best to ensure that the positions of nodes as well as the nodes' width and height are whole numbers.
I would suggest to round-off the x and y values of the position of tileNode and see if it will make any difference .
I'm guessing there is no gap. you probably have 'showPhysics' to true in your gameviewcontroller, and the line appears as a gap to me.
compare position with and without the pb to verify.
I had similar problem where gaps between sprites started appearing after around 5 minutes of scrolling with constant speed (game with infinite scroll). I did not use physics and I even had all positions, widths, heights rounded to integer value. I was scrolling the camera and adding new sprites one right after another and everything was working fine except after around 5 minutes of that infinite scrolling gaps begin to appear just as in your case. I spent some time in looking for a solution and it turned out that the problem was that when positions of my objects were becoming big that is in my case X position in the scene was around 150000 then those gaps started to appear and also I noticed that this problem occurred only on devices which had to scale the scene. I was using aspect fill with default scene size for iPhone 6 resolution and those gaps only appeared on iPhone 5 but on iPhone 6 I did not notice them. I was able to fix that issue by subtracting some constant value from X position of all objects (including camera position) from time to time so that everything on the scene relatively did not change position to the camera and look the same but actually absolute positions were changed to keep them low. I guess that larger position values like 150000 and scene scaling cause some floating point rounding issue in SpriteKit and that is why gaps are then becoming visible.
So based on my experience if you have similar gaps I recommend using integer values for all positions, widths, heights and additionally keep values of objects positions of all objects low.
For future reference in case someone is still searching for this, here are my experiences:
If tiles have PhysicsBodies, they are prone to making gaps. A solution for me was making a blank SKNode as a child of the tile, and assigning the PhysicsBody to that.
If possible, make sure bit masks are set in a way that tiles can't collide with each other.
As stated in a previous answer, make sure all measurements are integers and rounded in a way that doesn't leave a one unit gap between them.
A related problem is also SpriteKit's PhysicsBody drifting. There are some threads about this (e.g. https://forums.developer.apple.com/thread/27057 ), and it seems to be abug. In my case, the problem was a combination of PhysicsBodies causing random small gaps, and the drifting making some of them larger. The steps above removed the small gaps. Unfortunately the only workaround for the drifting problem in my case was to only generate PhysicsBodies for nodes that are within a certain distance from the player and destroying them after they are left behind.
For future reference for anyone who needs, I found an different answer specific to my problem. As JohnV said, I may need to round of values when setting the position, but when running the code, I found out that I also need to do that when running SKActions.
I've been suffering from an issue regarding the implementation of orienting characters in a game I'm implementing using Ogre3D and Bullet physics.
What I have: A Direction Vector that the character is moving in, along with its current orientation.
What I need: To set the orientation of the character to face the way it is moving.
I have a snippet of code that sort of does what I want:
btTransform src = body->getCenterOfMassTransform();
btVector3 up = BtOgre::Convert::toBullet(Ogre::Vector3::UNIT_X);
btVector3 normDirection = mDirection.normalized();
btScalar angle = acos(up.dot(normDirection));
btVector3 axis = up.cross(normDirection);
src.setRotation(btQuaternion(axis, angle));
body->setCenterOfMassTransform(src);
Where 'body' is the rigidbody I'm trying to orient.
This snippet has a couple of problems however:
1) When changing direction, it tends to 'jitter' i.e. it rapidly faces one way, then the opposite for a second or so before correcting itself to the orientation it is supposed to be at.
2) Most times that the code is run I get an assertion error from Bullet's btQuaternion on
assert(d != btScalar(0.0));
Can anyone help?
Thanks!
I think you shouldn't use functions like 'acos' for such things, as it may cause some inconsistencies in border-cases as the 180 vs 0 rotation mentioned above. You can also get high numerical error for such data.
The second thing is that - in general - you should avoid setting explicit position and rotation in physics engines, but rather apply forces and torques to make your body moving as you want. Your current approach may work perfectly now, but when you add another object and force you character to occupy the same space, your simulation will explode. And at this stage it's very hard to fix it, so it's better to do it right from start :) .
I know that finding correct force/torque can be tricky but it's the best way to make your simulation consistent.