I'm doing my first steps in spriteKit, i only have two scenes, in the second one i have a method which spawns little pixels (rocks) and they fall down with the physic. The other thing I have is a parallax effect with a image.png which size is 323x90. The image move in the background from left to right and when it disappear in the right it spawns again (i don't destroy the node, only change it's position) in the left and begin again the animation.
When the rocks are falling, the node max count is 20 - 21 but my FPS drop to 20-21. This is beginning to slow down and i don't understand why, i wonder what will happen when my scene grows up. I've tried with iphone 5 simulator and is the same. Does any one know why?
Related
I have been trying to achieve the animation in this link: http://www.visa.com/rio2016/na-en/#!gallery on an iPad. Try opening this link on and iPad and you'll see.
Basically, its a wrapped(360 degree/Infinite) horizontal list. If the user moves in circle the list on the device should follow the movement.
I know that JS uses webkitCompassHeading to calculate the compass readings.
I tried using the accelerometer but the issue is the deceleration factor is quite small. Lets say I am am moving in right circular motion, list scrolls backwards or from right to left, everything is fine. I stop and start moving in reverse, the deceleration is there but for a very short time. So for the reverse movement, only 1 or 2 carousel items gets scrolled forward or left to right and again since the accelerometer picked the +ve acceleration, the list starts moving in backwards or from right to left direction.
Tried it with magnetometer, by storing the last angle of rotation and seeing if the new one has changed by 6 or 7 degrees but the values are too shaky.
I am trying to make my game character loop around the screen infinitely like this: http://i.imgur.com/F2yuqen.gifv
Basically, there are three characters. One spawns in the middle of the screen, and the other two spawn exactly the screen width away on opposite sides and move with the main player. Once the main player's x position is less than 0, or greater than the screen width, it is placed back into the middle of the screen. This makes it infinite in essence.
It works great in processing, but in swift my variables for screen width self.size.width seem much larger than the actual screen width when I run the game in the iOS simulator. This makes the character movement not seem smooth and if it is cut off on one side, it does not show up on the other side like it does in the first example.
Example: http://i.imgur.com/gLS4ijK.gifv
Again, I think it has something to do with self.size.width not actually being the width of the display in the simulator.
Code:
Figured it out, I had to add
scene.size = skView.bounds.size
to GameViewController.swift
This is something I've been struggling with for a while now, and I'm really hoping someone can shed some light on the issue. Basically, I have a scene with a bunch of colliding SKPhysicsBodies. If I put the camera in the middle of the action on the very first frame of animation, the entire simulation runs at about 17fps indefinitely. However, if on the very first frame of animation I start the camera off-screen such that nothing (or very little) is drawn that first frame, and then move the camera to the middle of the action on the 2nd frame, then the simulation runs at 60fps.
The simulation is exactly the same in both cases. Nothing is different other than what sprites are culled on the very first frame, yet that seems to make all the difference for the rest of the simulation's performance.
This has proven 100% reproducible in every case I come up with, so in order to make sure that my game runs at 60fps, I have to "prime" the camera by starting it way, way off-screen, render a frame, and then move the camera to where I really want it to be. If I don't do that, the game runs at a cripplingly low frame rate and will never speed up.
I have an object that is moving very fast (max velocity 900). When it reaches max speed it starts to create trailing objects or motion blur.
But I just want it to be the object moving fast. I am running on 60 fps.
I like the speed of the object but I don't like how its getting rendered (motion blur). How do I handle this?
This object bounces all around the screen with a restitution of 1.02, because I want to make it pick up speed as it keeps bouncing. I want to make it go faster thats why I did the 1.02 restitution.
The motion blur may simply be due to the LCD display having an "afterglow". So the position the object was in the previous frame is still a little brighter in the next frame because it takes some time for the crystals inside the LCD to return to the unlit state.
This causes "motion blur" on any moving object on the screen, and is of course more noticeable the faster the object moves. You may even be able to make out multiple versions of the same objects at different light levels trailing behind the object's position.
This effect may also depend somewhat on the device and model, and is often called 'ghosting'.
Regardless, there's nothing you can do about the "motion blur" caused by the LCD screen's afterglow effect. Here's a good article explaining the effects and their causes.
Hmm... you'll have trouble getting it to render smoothly.
At that speed (900 points per second) it will move 15 points every FRAME if running at 60 fps. That's a significant amount to move in such a short amount of time. In about 1/3 of a second it will travel entirely across the screen.
I'm guessing it will be getting to the limit of the ability of the hardware. Both the processor, the screen and your actual eyes. I imagine you'll also hit physics errors too with it possibly escaping through walls etc...
Can you show a video of how it is currently behaving?
In my Corona SDK game I would like an item to drop from the sky and bounce up and down a few times before settling, at a randomly designated point on the screen. Say I'll drop an item at X=500 and Y=0. I then designate a drop-off point at Y=700, where the item will drop all the way til Y=700, bounce back up, then down, and after a few times (depending on bounciness), settle down and stay there.
This game is 2.5D, so having a static physics ground at the bottom would not work.
To do this, I came up with two options, neither which worked well:
Make a temporary invisible, 2x1 physics platform at the point where I would want the item to hit and bounce back up and down. This platform is created the moment I drop the item, and deleted when the item has settled down (fell asleep).
Inject force or change the linear velocity when the item passes a certain point.
However, because my gravity has been set to 40 (normal gravity of 9.8 was too floaty), the item will literally vibrate once it has stopped bouncing at the platform, and oscillate between velocities of 20 to -40 (varies) and not go to sleep.
The Injecting force method has also caused weird results, because the code checks the velocites per enterFrame event, so the results are not consistent.
I think the invisible bar is what makes the most sense. I would consider lowering the gravity back to something closer to normal and play with the bounce and density to get the bouncy that you want.