What i want to do is record the time of when a button has been pressed. All these times will be stored in an array. The program will then run through the array and look at the time values and then highlight the button states at those particular times during playback.
Hopefully this makes sense, whats the best way to do this?! Thanks in advance.
------------------ MORE DETAIL ------------------
the first thing that came up on my mind was... 'ah ha, timestamp', but then looking into the documentation, in a certain section in the timestamp page somewhere in the paragraph it states the following:
....You should not use it to determine the exact time at which the event occurred but should instead compare it to the timestamp of another acceleration event to determine the elapsed time between the events....
this is not great.. as i am assuming that it will not be accurate when it comes to playback of highlighting the buttons at the exact times of when the user had actually pressed them during record.
Please let me know of what i should use and do.
The -[UIEvent timestamp] property will be the most accurate representation of when the touch actually occurred. If you use CFAbsoluteTimeGetCurrent() or the UNIX time() functions you will get the current time the moment function is called, not when the event actually occurred (which will be sometime earlier).
You can use CFAbsoluteTimeGetCurrent() to get the current time expressed as the number of seconds (as a double value, so fractional seconds will be there) since January 1, 2001 00:00:00 GMT.
Hence, you should record the value of CFAbsoluteTimeGetCurrent() at some point when your app starts, and then record its value every time a button is pressed. Then, by subtracting the time the app started from the time the button was pressed gives you the number of seconds the button was pressed since the app started. You can then play back the button presses at a later time by taking that time delta and adding it to the time when playback started.
Related
I've lost track of how many questions & responses I've read while trying to find an answer on this. The ones that sound like they're related often aren't, or else the users are just accused of being confused. (As an example, the first answer here just tells the person asking the question that they don't really mean to be asking what they're asking. Then there's this one. The most upvoted answer here says it's just impossible. Etc., etc., etc.)
I need to be able to take a time--say 9:00 AM--and work with it as 9:00 AM regardless of which timezone my user is in. If a user pulls up this time in a US/Eastern timezone, they should see this value as 9:00 AM. If a user pulls up this time in a US/Pacific timezone, they should see this value as 9:00 AM. I recognize that this is not actually the same moment in time, and I don't need it to be.
To illustrate, let's call the timezone-immune timestamp I'm talking about timezoneImmuneTimestamp, and say that its value should always be 9:00 AM.
Say I'm executing someMomentInUsEasternTimezone.diff(timezoneImmuneTimestamp, 'minutes'), where someMomentInUsEasternTimezone is equal to 10:00AM (EST). The answer I need is 60 minutes.
Now let's add another Moment, someMomentInUsPacificTimezone and say its value is 11:00AM (PST). When I execute someMomentInUsWesternTimezone.diff(timezoneImmuneTimestamp, 'minutes'), the answer I need is 120 minutes.
Has anyone else had this particular problem, and more importantly, solved it?
It sounds like you want to work with only the "wall time" of each moment object. To do that, first create a clone of each moment and set their offsets to zero, as if they were UTC. When doing so, pass true to keep the wall time instead of the same point in actual universal time.
This is described in the docs for the utcOffset function:
The utcOffset function has an optional second parameter which accepts
a boolean value indicating whether to keep the existing time of day.
Passing false (the default) will keep the same instant in Universal Time, but the local time will change.
Passing true will keep the same local time, but at the expense of choosing a different point in Universal Time.
Thus, to get the difference in minutes between momentA and momentB with respect only to wall time:
momentA.clone().utcOffset(0, true).diff(momentB.clone().utcOffset(0, true), 'minutes')
Though missing from the docs, the same argument can be passed to the utc function. So if you prefer, you can shorten it to:
momentA.clone().utc(true).diff(momentB.clone().utc(true), 'minutes')
(Cloning helps the rest of your code by not mutating the original moment objects.)
Also - The Moment team highly recommends only using Moment in legacy/existing code. If you are writing a new application, please try Luxon instead. In Luxon, the setZone function has a keepLocalTime option that does the same thing as I showed in Moment.
I am currently doing a simulation model in AnyLogic of a Distribution Center where from Monday to Saturday I use an event to trigger the loading of a truck. I wish to program this loading every day at the same time, but how can I do it so it happens everyday EXCEPT Sundays. I currently have it as triggered: timeout and mode: cyclic, using calendar dates...
sure, the easy way is to just add a manual exception to the schedule as below:
And the more advanced way is to use a Dynamic Event that executes your daily action.
In the model start code, call create_MyDynamicEvent(7, DAY) to make it trigger after the first 7 days of the sim.
Then in the Dynamic Event action code, add whatever should happen every day. And also add a line that re-creates the same Dynamic event in 1 day, like
create_MyDynamicEvent(1, DAY)
This would then trigger every day, even Sunday. To avoid that, you can add an if-clause in the dynamic event action code to only execute your code if it is not Sunday.
How can i damage my FirstPersonCharacter's health constantly while it's in the trigger zone? It loses its damage only when it enters onBeginOverlap on the trigger zone.
Here is my blueprint:
Create Timer with your DamageOverTime function and call him every X sec, until onEndOverlap occur.
simple example:
Here you can find much more about timers in BP
In c++ I would connect it either to the time handle or Tick event which is using delta seconds, but I'm not into blueprints yet so I can give you a small advice to start off with.
You need a loop and check if the character is in the zone or not. The easiest way is to set a bool variable, set it to true when it enters, and keep damaging while the variable is true and stop it when it's set back to false (when he leaves the zone).
Hope it helps a bit.
I've created a function to calculate time difference between current time and time recorded as StartTime. All calculations are perfect but my "StopWatch" won't update every second. Is there a way of updating it, so it can display every second elapsed since start point?
Window refreshing script isn't an option really.
Short answer: no.
There is nothing in Filemaker that will happen as a result of merely time passing - except for a script paused for a duration or installed on a timer.
To show a live, ticking clock, your best option would be to use a web viewer - see an example file here: http://fmforums.com/forums/topic/71934-calculating-elapsed-time-realtime/?do=findComment&comment=340205
I'm starting to work on an app similar to tamagotchi (virtual pet kind of stuff) in the Corona SDK. I got absolutely stuck and am out of ideas on how to get one part.
How can the game character, lets say "pet" change its status, e.g. become hungry or die while the game is inactive? Or maybe its possible to make the changes as the player enters the game the next time, maybe to bind it to the global time (still no idea of how to do it)?
I would appreciate any help.
The simplest I can think is to keep all relevant data in a file. The first datum would be a time stamp of the last time the game was turned inactive.
Every time the game is first activated it reads the file along with the time stamp. After a specific time length has passed the pet becomes hungry, tired, etc. If an extraordinary long time has passed the pet dies.
You can go further by putting a time stamp next to each datum like "last fed", "last watered", etc. and then you can make individual attributes expire at different times, including death by boredom by keeping the global "last active" time and if a long time has passed without running the game the pet dies.
I actually created an application like this. I created a number of states in a enum and then in a checkMoodState method I hardcoded the values that decided the state of the mood.
e.g.
timeSinceLastPlay
timeSinceLastFeed
or whatever.
Either write the dates to a plist for each variable you want to track and on each check or store them in NSUserDefaults(one function to write them all, one to load them all), subtract the current time from it. You will be left with a negative number, and you can just get its absolute value.
You decide whenever you want to check the last time since whatever it is you are checking, e.g. feeding. Create an NSTimer with the duration of the time between checks and in the method called by the timer, you do you checks and update the mood as you need.