ArianeSoft - Programming and development for Windows and Windows Mobile :: Forums :: PPL - Pocket Programming Language :: Code sharing
 
<< Previous thread | Next thread >>
Component Classes?
Go to page  1 [2]
Moderators: kornalius, bmanske, PointOfLight
Author Post
zehlein
Fri Nov 02 2007, 10:35am

Registered Member #30
Joined: Tue Sep 12 2006, 03:00pm
Posts: 449
Yes, to remove the text from the statusbars' surface simply redraw the original panel (or at least the part of it you want to clear)
Maybe you can imagine your original approach like a graffity (your text) sprayed on a wall (your sprite's surface). There is no other way to get rid of it as to repaint the wall. My approach is rather like pinning a sign (the textsprite) to the wall (your sprite's surface again). You may easily remove the sign and replace it with a new one.
As a child-sprite the textsprite should move with it's parent, at least that is what the online help states. Didn't try it myself...
Quote from the help:
"Notes:

hild's location will always be relative to the screen's location

While moving Parent, children sprites will move with it"



There is a crack, a crack in everything. That's how the light gets in. (L. Cohen)
Back to top
Donone
Fri Nov 02 2007, 10:38am
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
I have finally laid to rest the last cause of the TOP saga.
zehlein said:
The reason for the errors on Text1 and Top calls resides in your class definition
yor code:
public proc Text1(t1$)
should rather read:
public proc dsStatus.Text1(t1$)


Just for future reference this is not correct, the bold portion is only required outside the class. I assume you simply misread my code.
Removing all those references and finally the one in Create, solved the access violations.
[EDIT] I just got caught out by the page[2] yet again, I didn't see the tag and assumed you had not yet replied. I tried paent child but it didn't work. I'll keep trying. Also the redrawing, when I figure how to cause it

[ Edited Fri Nov 02 2007, 10:41am ]

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
Donone
Fri Nov 02 2007, 11:48am
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
It's no good, I cannot find a suitable function. Having created the text sprite and made it a child of the statusbar so that it moves with it, I cannot remove it.
There doesn't appear to be a function DelChild. The text sprite doesn't have a name and only exists in a child list. I cannot gain access to individuals of that list to delete or remove it so that I can create a new text sprite.
I need the opposite of SetSpriteParent and don't understand why there isn't one.
We seem to have a lot od SET items but none to undo them. DelSprite(Sprite$,Child$)) doesn't work.
Any pointers??

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
PointOfLight
Fri Nov 02 2007, 01:28pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
I don't understand how your child sprite can't have a name?  In order to use SetSpriteParent you supply two parameters, the first of which is the child sprite.  So let's say you have:

father$ = newsprite(null);
son$ = newsprite(null);

SetSpriteParent(son$, father$);

if you want to get rid of son, why not just do DelSprite(son$); ?

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Donone
Fri Nov 02 2007, 01:45pm
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
I cannot believe you got here before me (if you read my reply to you on the support forum.
However, didn't try the obvious, because I made an assumption that because what eventually became the child sprite was created inside a procedure and Local. I had left the procedure and was now returning to delete that child and replace it with another new one. Being local it should have been gone. Maybe it should be private.
The cycle to repeat any time I change the text using g_cacheText.

The other question is how do I clear text using g_textout? I tried using spaces to overwrite first, but no. The text is on a surface which still exists. I expect to be able to obtain the surface as before and alter it then reattach it to the sprite and hey presto. Not to be.
Sorry to be such a burden.
  public proc Text1(t1$)
  t$=t1$;
    surface$=SpriteSurface(Sprite$);
    oldSurface$=SetRenderTarget(surface$ );
    g_beginScene;
// CANNOT FIGURE how to clear the text firs t, this doesn't work
    g_textout(NULL, "     " , 0, 1, 1, g_rgb(255, 0, 255));
    g_update;
    SetRenderTarget(oldSurface$);
    oldSurface$=SetRenderTarget(surface$ );
    g_beginScene;
    g_textout(NULL, t1$, 0, 1, 1, g_rgb( 255, 0, 255));
    g_update;
    SetRenderTarget(oldSurface$);
  end;


[EDIT] No matter what I do with Global, Private etc. the child does not exist under its name.
  public proc Text1(t1$)
  
  if(varexists(s$))
    DelSprite(s$);
  end;
    f$=G_LoadFont("Arial" ,9,RGB(255,255,255),FONT_NORMAL,-1);
    cts$=g_CacheText(f$,t1$, 49,13);
    s$=NewSprite(NULL);
    SetSpriteSurface(S$,cts$,1,0);
    SetSpriteParent(s$,Sprite$);
    MoveSprite(s$,Left$,Top$);
  end;


[ Edited Fri Nov 02 2007, 02:09pm ]

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
PointOfLight
Fri Nov 02 2007, 02:38pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
First of all, I think you are overusing g_beginscene and g_update. In fact, you shouldn't need them if you're using a call to RenderSprites somewhere. Is this drawing done outside of the normal GameAPI rendering routines? Anway, here's a modified bit of code:

public proc Text1(t1$)
  surface$=SpriteSurface(Sprite$);
  oldSurface$=SetRenderTarget(surface$);
  //  g_beginScene;
  //CANNOT FIGURE how to clear the text first, this doesn't work
  g_clear(G_RGB(0, 0, 0));
  //g_update;
  //SetRenderTarget(oldSurface$);
  //oldSurface$=SetRenderTarget(surface$);
  //g_beginScene;
  g_textout(NULL, t1$, 0, 1, 1, g_rgb(255, 0, 255));
  //g_update;
  SetRenderTarget(oldSurface$);
end;

Now you should eventually be able to get rid of the code that is commented out.  If for some reason you really need the g_beginscene and g_update, put them at the very beginning and very end of the routine.

As for the child sprite problem, can you show where the sprite variable is initially declared in your class?


Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Donone
Fri Nov 02 2007, 02:53pm
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
Thanks I'll give this a go. I confess that a lot of my attempts are trial and error, because I find a need for something, then scan the functions in the help file hoping to spot something relevant and then try it. It is difficult, I think, to do anything else unless you know the system well.
The beginscene etc. was by duplicating the original scene change and then changing the text to spaces. I thought I would have to render that first and then the new text.
As you can see I have two methods of text going at the same time, and whichever gets solved first I will use.

The declaration of the child sprite was simply its first use in the procedure you see at the end of the post above yours. Then I tried Private straight after the Class declaration to make it useable anywhere within the class but not outside.
I post the whole thing below. A lot of what is in here is now obsolete and it needs tidying.
It is operated by clicking the statusbars and clicking the empty screen several times.
1194029583_231_FT7445_waypoint.zip

[EDIT] I tried your mods and it seems to have cured the text but the statusbars disappeared. I changed the screen to white and I could then see where they were but they were black only and no panels. I have had this colour problem before and don't understand it.

[ Edited Fri Nov 02 2007, 03:01pm ]

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
Donone
Fri Nov 02 2007, 03:05pm
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
This is the only way I can see to upload a file; by another reply. This is the program you provided the latest code for. The status bars got lost.
1194030330_231_FT7445_statusv6.zip

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
PointOfLight
Fri Nov 02 2007, 03:52pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
Here's a slightly modified version of one of your attempts.  I eliminated the need for a child sprite and for caching the text (both really not necessary for what you're doing).  You'll probably still need to tweak the text drawing a bit more, but this should get you in the right direction.
1194033173_49_FT7445_waypoint.zip

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Donone
Fri Nov 02 2007, 04:24pm
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
Thank you very much. By the way some of the code sequences I use come from the help file . Most of the beginScene etc. comes from there.

The program gave an instant error which was caused by the use of waypoint.DrawBar inside the class, which should be just DrawBar. I already spent hours solving a similar problem today.
However IT WORKS, the text is displayed and cleared correctly (naturally). Thank you. I shall now study it more closely.

q1. Can you give more or point me to, more information on how the colour works, especially transparent colour and mask. I have noticed every so often a bad code causes black and white results.

q2 I have a question regarding your info on surfaces, at your leisure please.
By using SetRenderTarget, does that render automatically or do I need to g_update?

I should like to write a note on what I understand about surfaces from reading your post and pass it by you in a day or two to see if I have comprehended. If this is acceptable should I just post it?

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
PointOfLight
Fri Nov 02 2007, 05:16pm

Registered Member #49
Joined: Sun Sep 17 2006, 03:02pm
Posts: 1129
If you want to send me a PM about surfaces that's perfectly fine.  The only advantage to posting it is that others may learn from it as well.  I would consider starting a new topic about it if you decide to post, however.

As for the Waypoint. syntax, I wonder if that is due to a version difference.  I am using the latest build, and I could not compile the code UNLESS I prefaced the DrawBar function with the name of the class.

SetRenderTarget doesn't actually have anything to do with the final rendering to the screen.  It just determines which surface your drawing routines will apply to.  Unless you tell the GameAPI to not autoupdate, the screen will be redrawn every game cycle.  That's when the WM_PAINT message gets called.  At that point, it's up to you to determine what gets drawn to the screen.  In your sample, the only two things being done to the screen are that it's being cleared (g_clear), and sprites are being rendered (RenderSprites).  Since you chose to make your progress bar a sprite, that's why it gets rendered without any additional work on your part, and why you don't need to call the g_beginscene and g_update functions.

Eric Pankoke
Founder
Point Of Light Software
http://www.polsoftware.com/
Back to top
Donone
Fri Nov 02 2007, 06:52pm
Registered Member #231
Joined: Fri Jan 12 2007, 10:17am
Posts: 626
Very useful and thank you once again.

You only stop learning when you die.
Sometimes I think I am dead
http://www.don-simmonds.co.uk
Back to top
Go to page  1 [2]  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System