>
>  I've tried not using a thread and using a View instead but then I
> couldn't find something convenient to refresh regularly my canvas.
> Calling invalidate() in onTouchEvent() does not render very well (remember
> that I'm working on a game so…) and using postDelayed worked but then
> onTouchEvent seem to be called only once.
>


Did you try calling postInvalidate() in your onTouchEvent() method?  I've
done that before and it worked well for me...
http://developer.android.com/reference/android/view/View.html#postInvalidate%28%29


Thanks,
Justin Anderson
MagouyaWare Developer
http://sites.google.com/site/magouyaware


On Sun, Mar 18, 2012 at 4:31 AM, Sheeft <ishe...@gmail.com> wrote:

> Hello everyone !
>
> I'm experiencing some issue with a game I'm working on.
>
> I'm using a SurfaceView linked with a thread to draw on it but when using
> a thread as follows, my view onTouchEvent method never gets called.
>
>> public void run()
>>
>>     {
>>
>>     Canvas c;
>>
>>     while(_run)
>>
>>     {
>>
>>     c = null;
>>
>>     c = _surfaceHolder.lockCanvas();
>>
>>     if(c != null)
>>
>>     {
>>
>>     _view.onDraw(c);
>>
>>     _surfaceHolder.unlockCanvasAndPost(c);
>>
>>     }
>>
>>     }
>>
>>     }
>>
>
> I've no idea how to fix that anyway…
>
>  I've tried not using a thread and using a View instead but then I
> couldn't find something convenient to refresh regularly my canvas.
> Calling invalidate() in onTouchEvent() does not render very well (remember
> that I'm working on a game so…) and using postDelayed worked but then
> onTouchEvent seem to be called only once.
>
> Hope you can help me.
>
> Thanks a lot !
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to