I know that the Node's update method will be called every frame if we call scheduleUpdate for the current node. Is the delta parameter in the update method the same on all devices and platforms? If not, then how can I calculate what the frame rate or the delta value is on the device running my game?
I the AppDelegate you will see a line like below:
director->setDisplayStats(true);
If the value passed down is set to true you will see the frame rate of your game in the bottom left corner. You can follow that code to see how they calculate the FPS, if you want to add constant frame rate functionality to your code.
[EDIT: Based on the comment below]
The way I have done what you want in the past is by having a dedicated game controller which has a scheduled update function and I use that to set a delta value that can be passed around or accessed by other components of the game.
Related
Ok, I've been using Godot for a while now, and haven't really had any issues. But, after I added an area2D to detect the player and teleport them as shown below that I run into issues. Every time I start the game, the console shows that both of the functions have already been run, even though the starting location is nowhere near the area2Ds. In addition, because they run in enter -> exit order, it spawns me at the exit of the tunnel, instead of the start of the map.
func _on_Tunnel_body_entered(_body):
print("entered_tunnel")
global_position.x = 952.5
global_position.y = 487
func _on_TunnelBack_body_entered(_body):
print("exited_tunnel")
global_position.x = 920
global_position.y = 635
Any help would be appreciated!
Are you, by chance, instancing the player character, adding it to the scene, and then setting its position (in that order)?
That is a common reason for this problem. What happens is that it collides with the areas once you add it to the scene but before you set its position.
To solve it set the global position before adding it to the scene.
You could temporarily disable the behavior by any of these means:
Temporarily changing the layers and mask to avoid the collision (you can do it with set_collision_layer_bit and set_collision_mask_bit).
Temporarily disabling collision shapes (by setting disabled to true. However, use set_deferred to avoid disabling it while Godot is still doing physics computations)
Temporarily adding collision exceptions (by calling add_collision_exception_with and remove_collision_exception_with).
Having a flag that you can check in the function that takes the signal to decide if it should take effect or not.
Connecting the signals from code once, so they are not connected beforehand.
I need to send Geolocation to server in 2 scenarios.
1. particular time interval,say 300000 ms(configurable)
and
2. whenever device moves a particular distance,say 500 mtrs(configurable)
First scenario has done using setInterval() in javascript.
How can i raise an event based on distance.
I am using jquery Mobile with phonegap/cordova.
Thank in advance.
Is there any way to measure time from starting flash without using system time? System time can be changed by user when flash running
I'm also not sure what exactly you mean but if you want to grab a time which cannot be altered by user you could e.g. call a webservice and get "accurate" time.
Check this website here http://www.earthtools.org/webservices.htm.
By passing parameters for a certain region to the request you will get the appropriate time.
Other than retreiving time from a server there is no way to make sure the (system)time has not been altered by user.
There is also a function called "getTimer()" which returns the number of milliseconds that have elapsed since your app started. Refer to this url:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/package.html#getTimer()
The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the timer.start() method to start a timer.
Add an event listener for the timer event to set up code to be run on the timer interval.
how to make a game tutorial as farmville game tutorial to teach the user to play the game. i have recently involve in make that kind of game tutorial for its user by actionscript 3, can anyone give me a guide to do it? any help is appreciated~
A common way to do this is similar to the "achievements system" many games employ, which utilises the a system similar to the Observer design pattern.
You'd set up a globally-accesible receiver object, with a function to receive a data packet of some sort.
Then, every function that should effect the tutorial info being shown would message this receiver object, and tell it of it's performed action.
So, say for instance, that you have a message box up to tell the player to "Chop down 10 trees".
You could then have a Receiver object with a function like TutorialMessage(var Action:String, var Parameter:object):void
When they perform the "Chop down tree" action, then end of the chopDownTree() function would contain a call to the receiver object's messaging function Receiver.TutorialMessage("TreeChoppedDown", 1) (ie, Chopped down 1 tree).
That receiver would then, essentially, run a massive switch case to determine the nature of the action, and interpret would to do based on your logic. In this case, it would add the value of Parameter to some counter variable, and when it reached 10, would display the next tutorial message.
I'm trying to determine an initial value for NetStream.bufferTime based on the client's calculated bandwidth and the video's bitrate.
As far as I can tell you can't do this, because you must have an initial buffer set BEFORE you call NetStream.play() (or use the default 2 seconds) and FMS does not call NetStream.onMetaData, where one would normally find the videodatarate, until after NetStream.play() is called.
Even if you modify NetStream.bufferTime during the onMetaData call back it doesn't effect when the video starts playing or when the NetStatus event registers "NetStatus.Buffer.Full".
Therefore my question is:
How do I find the Video Data Rate BEFORE I call NetStream.play?
-Or-
How do how do I reset the initial bufferTime before acctual play back begins and the NetStatus event fires with "NetStatus.Buffer.Full"