Trouble when drawing and erasing onto a canvas

Game Editor comments and discussion.

Trouble when drawing and erasing onto a canvas

Postby elfdav » Sun Sep 30, 2012 12:17 am

Hi Everyone,

I got a problem with a drawing program again...

Here is the details:
When i draw something and then i erase a part of the draw, the event click is no more catched if you click from the erased part.

The official doc say "A canvas must have a color present to receive an event".
It also say to fix this use a filled region larger than the canvas. With this, all the mouse event will be catched.
I tried this solution and it works.
- But -
If you run the DrawTest program, you click on the pen and you can see the current x, y mouse are always the preceding one.
It is not supposed to be the case because i use the "moveto" function to refresh it each time.
As a result, lines appears (from xpreviousmouse, ypreviousmouse to xcurrentmouse, ycurrentmouse) instead of just "normal draw" (it means just draw from current mouse position without any lines) Notice that all mouse click are effectively catched all time.

Now, if you remove the Filled Area and just let the canvas alone, the program run perfectly but the catching mouse problem will be there again.

The strange thing is the following: Canvas and Filled region contains EXACTLY the same code to draw !

So why the Filled Region does'nt works the same way the Canvas region ???

Thanks to anybody will explain me what's happening here...

David
Attachments
TestDraw.zip
(7.86 KiB) Downloaded 110 times
elfdav
 
Posts: 14
Joined: Sat Feb 14, 2009 4:18 pm
Score: 0 Give a positive score

Re: Trouble when drawing and erasing onto a canvas

Postby skydereign » Sun Sep 30, 2012 2:25 am

The problem is that the actor calling moveto is the filled region. moveto is a canvas only function, and it is canvas specific. In your case you should send an activation event to the canvas, so you can trigger the moveto code with the canvas being the event actor. If you aren't familiar with activation events, they can be extremely helpful working around things like this.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Trouble when drawing and erasing onto a canvas

Postby elfdav » Sun Sep 30, 2012 5:01 pm

Can Skydereign or anybody else give me more details about this explication, because i'm not quiet familliar with Activation Event.
I tried many ways to correct the situation but i can't find the right one. Since i have to produce a demo quickly, can anybody explain me how to do what Skydereign has described ?
Thanks !!!
elfdav
 
Posts: 14
Joined: Sat Feb 14, 2009 4:18 pm
Score: 0 Give a positive score

Re: Trouble when drawing and erasing onto a canvas

Postby skydereign » Sun Sep 30, 2012 6:00 pm

Here is the updated ged. All I did was the following. Change the mouse button down for the filled region, setting GODRAW equal to 1, and sending an activation event to the drawing area actor. Then added an activation event for the canvas, that has the screen_to_actor and moveto. All SendActivationEvent does is trigger an actor's activation event. It is pretty straight forward. In this case you wanted the moveto code to be specific to the canvas (which means it would need to trigger the code). This method is how you make other actors trigger code.
Attachments
TestDraw.ged
(4.4 KiB) Downloaded 112 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Trouble when drawing and erasing onto a canvas

Postby elfdav » Sun Sep 30, 2012 11:58 pm

Sky, one more time, thank you so very much for your taking time to answer quickly!
Because of you i have learnt new stuff today.
It was important to me to learn it very quickly and what you gave to me is exactly what i was looking for.
David
elfdav
 
Posts: 14
Joined: Sat Feb 14, 2009 4:18 pm
Score: 0 Give a positive score


Return to GE - General

Who is online

Users browsing this forum: No registered users and 1 guest