1 decade ago
by davidx
Hi,
Is it possible to spawn an entity on a different layer?
What I am actually trying to do is spawn an entity at a "distance", so I have a sky layer that moves at half speed and I want to spawn birds flying in the sky.
So I have spawned the bird and pseudo randomly positioned it in the sky, but as the entity layer moves twice the speed, it looks a bit silly.
Anyone any ideas?
Thanks,
Dave
1 decade ago
by Alex
If birds fly too fast, reduce their speed?
edit: oh you mean when the player moves, the birds look/move silly in the sky?
1 decade ago
by davidx
Hi Alex,
Yeah, its when the camera is moving, the birds look silly.
I am experimenting with just setting the this.vel.x to different values and if the fps stay constant, I can get it looking good, but when they drop it looks funny so I guess I need to play with the ticks...
More trial and error!
Thanks,
Dave
Do the birds need to be entities? Could they instead just be an animated background map above your base background?
1 decade ago
by davidx
@paularmstrong
Yeah, I thought of that too, but what I want to do is only spawn a certain amount of these based on what the fps is.
i.e. if the game is only running at 20 fps, then I don't spawn any, if its 40 fps, spawn 10 etc etc. I do this in main.js draw loop by checking the ig.system.tick property.
So really what I need to work out is how to set the speed of the entity based on the scroll of the background which is based on the distance.
So, Ill experiment with a few things and see.
Thanks,
1 decade ago
by davidx
Hi,
I have still had no success getting this to look correct.
If anyone has any suggestions, that would be great.
Thanks,
Look into how parallax scrolling works. You can fake this effect simply by having each iteration of an entity move at slightly different speeds with a random z-index too.
Something like the below link should help you generate random numbers in a range. You can use that to set the speed and z-index in the entities init() function. :)
http://roshanbh.com.np/2008/09/get-random-number-range-two-numbers-javascript.html
Page 1 of 1
« first
« previous
next ›
last »