ios - UIImageView jumps around -
i call method every 0.2 seconds send uiimageview position via socket.io:
- (void)update { cgpoint touchlocation = blue.center; if (!cgpointequaltopoint(touchlocation, lastlocation) && !isanimating) { nsdictionary *json = [nsdictionary dictionarywithobjectsandkeys:@(touchlocation.x), @"x", @(touchlocation.y), @"y", nil]; [socketio sendjson:json]; lastlocation = touchlocation; } }
when other device recieves data, it's displayed so:
- (void)socketio:(socketio *)socket didreceiveevent:(socketiopacket *)packet { int x = [[packet.name valueforkey:@"x"] intvalue]; int y = [[packet.name valueforkey:@"y"] intvalue]; [uiview animatewithduration:0.2 animations:^{ [red setcenter:cgpointmake(x, y)]; }]; }
even though animated movement, animation jittery/jumpy on receiving side. send raw data touchesmoved:
i'm sending lot of data. i've tried changing update interval 0.05 i'm sending 100 packets every 5 seconds per player. lot? there better way this?
Comments
Post a Comment