ios - How to find if a view is tapped more than 2 times within certain time period in cocos 2D -
ios - How to find if a view is tapped more than 2 times within certain time period in cocos 2D -
i developing game in cocos 2d. in game need tap view number of times. if user attempts tap view beyond limit, should display alert.
please can help me find number of taps on view. of import number of taps not simultaneously. in total game user can tap number of times, after should not tap view.
you can nstimeinterval.
//decalre in interface file nstimeinterval mlasttaptime;
.
-(id)init { if(self = [super init]) { mlasttaptime = [nsdate timeintervalsincereferencedate]; } homecoming self; }
//in touch method
nstimeinterval currenttime = [nsdate timeintervalsincereferencedate]; nstimeinterval diff = currenttime - mlasttaptime; if(diff < 0.3 ) { //do whatever want if user press 0.3second } mlasttaptime = [nsdate timeintervalsincereferencedate];
ios objective-c cocos2d-iphone touch
Comments
Post a Comment