last day (15 days later) » 

10:58 PM
0
Q: swift - how to stop refreshing taps?

Swift101I have made a bit of code that when the user taps everywhere on the screen the points/score/taps will increment by 1. But the problem is then it counts how many continuous taps I make and then if I leave a 1 second gap between pressing it will restart the counter. Is there any way I could make it...

 
that is the only bit of code. I have added all the file
@Lamar I don't want it to refresh at all
 
how about tabsLabel.text = "Taps: \(tabsLabel.text.toInt() + tapCount)"?
 
@boidkan nop does not work
 
Oh sorry man, I am stupid I forgot about how the label has text besides the tap count. So my solution wont work.
You could always just keep a class variable that keeps track of the count and then in touchesBegan you increment it and then update the label. Shouldn't be that hard to figure out. You could also look at apple documentation on touchesBegan and understand how it works.
 
@boidkan do you have the time to show me an example of that please?
and yeah that solution did not work haha :D
 
10:58 PM
So why don't you give it a shot and show me how you think it would work :)
 
ok just a sec
umm I am not quite sure because I made a new file with that tap stuff and my real project I have the points incrementing when the player goes past the enemy/obstacle. I will show you my update and my touchesBegan on my real project, as I have points labels set up and stuff.
 
You could always link me to the project on github if you have it there
 
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {

super.touchesBegan(touches, withEvent: event)

if isGameOver {
restart()

} else {
square1.flip()

}

override func update(currentTime: CFTimeInterval) {

if wallGen.wallTrackers.count > 0 {

let wall = wallGen.wallTrackers[0] as PPWall

let wallLocation = wallGen.convertPoint(wall.position, toNode: self)
if wallLocation.x < square1.position.x {
wallGen.wallTrackers.removeAtIndex(0)


let pointsLabel = childNodeWithName("pointsLabel") as! PPPointsLabel
 
Going to head home will be on in 30 min or so.
 
I don't have github
and alright
 
11:06 PM
this is whole touchesBegan method?
 
yes
 

last day (15 days later) »