Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Is there a SetTextPhysicsOn()?

Author
Message
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 22nd Sep 2013 14:03
I can use SetTextPosition() to move a word around the screen but does SetTextPhysicsOn() exist so that I can easily bounce words off the screen edges?
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd Sep 2013 14:10 Edited at: 22nd Sep 2013 14:12
use a dummy bouncing sprite (same size of the textTotalWidth and textTotalHeight) and apply its position to your Text OBject
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 22nd Sep 2013 14:19
What a great idea! The texts should now appear to bounce off each other as well. My own ideas for doing this were incredibly complex. Thanks!!!
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 22nd Sep 2013 14:51
"use a dummy bouncing sprite (same size of the textTotalWidth and textTotalHeight) and apply its position to your Text OBject"

How do I get the position of the sprite as it bounces around at random velocities? I really need GetSpritePosition(). Does this, or a way around it, exist?
AgentSam
12
Years of Service
User Offline
Joined: 14th Mar 2012
Location: Virtual Space
Posted: 22nd Sep 2013 14:53
Use one of:

GetSpriteX(iSpriteIndex)
GetSpriteY(iSpriteIndex)

or

GetSpriteXByOffset(iSpriteIndex)
GetSpriteYByOffset(iSpriteIndex)

Cheers,
Agentsam
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 22nd Sep 2013 15:37
Now you have the commands (Thanks AgentSam

The idea is to get the bouncing sprite position (X,Y) after physics are updated
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 22nd Sep 2013 16:06
Unfortunately, the AppGameKit documantation states, "Dummy sprites will not update their stored angle and position with the latest physics versions, so calls to GetSpriteX, GetSpriteY, or GetSpriteAngle will return the last value you set. Setting the sprite's position will update the physics body to the position you set."

I am using AppGameKit build 107 if that makes any difference.
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 23rd Sep 2013 16:19
Now, finally, I get it. Creating a sprite that is transparent is not seen but does respond to GetSpriteX(iSpriteIndex) and GetSpriteY(iSpriteIndex).

This is probably what MikeMax meant when he suggested, "use a dummy bouncing sprite". I tried using CreateDummySprite() and got into trouble.

Now that I am using a real, but invisible, sprite it seems to be working (so far).

Thanks MikeMax and AgentSam.
MikeMax
AGK Academic Backer
12
Years of Service
User Offline
Joined: 13th Dec 2011
Location: Paris
Posted: 23rd Sep 2013 16:48
ho sorry yes .. i didn't talk about the CreateDummySprite() command sorry if it was ambiguous

--------------
AGK Chat (Alpha)
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Sep 2013 17:12
Here's how I would do it (easy to expand on):


Parragil para o mundo!
Rob from Scotland
21
Years of Service
User Offline
Joined: 23rd Aug 2003
Location: Scotland
Posted: 23rd Sep 2013 18:53
Well MikeMax, I just thought that it was funny how I could be so much like a dummy when I was trying to CreateDummySprite()

baxslash, I tried making the text into a sprite but ran into all sorts of trouble (tiny bits of the previous text appearing as part of the latest sprite). I might continue with my text objects flying around or revisit my textsprite idea using your method. Either should work but I might find the textsprite easier to work with than the flying text objects.

Of course, I might go in the wrong direction as I often do!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 23rd Sep 2013 19:19
Quote: "baxslash, I tried making the text into a sprite but ran into all sorts of trouble (tiny bits of the previous text appearing as part of the latest sprite)."

You probably just need to make sure you hide the text / sprites before grabbing each new image. Alternatively offset the view and text positions to an area of the "world" where you know nothing exists when you grab the image for the sprite.

Quote: "Of course, I might go in the wrong direction as I often do!"

Don't we all!

Parragil para o mundo!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 24th Sep 2013 17:22
Quote: "Alternatively offset the view and text positions to an area of the "world" where you know nothing exists when you grab the image for the sprite"


This used to crash, I don't know if it was fixed in the 108 betas? You could only copy on-screen coordinates, caused me a significant headache!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 24th Sep 2013 18:04
I'm not sure. Were you grabbing areas off the screen of changing the offset and grabbing coordinates that were then on the screen?

rem something missing here...
start : wakeUp() : gosub work : repeat : readStories() : until getKidsAsleep() = true : sleep(18000000) : goto start
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 25th Sep 2013 14:43
I was using negative screen coordinates. The "fix" was to use negative coordinates and move the world coordinates to put the area on-screen.

It may be fixed, I haven't checked for long time.

Login to post a reply

Server time is: 2024-11-24 19:26:27
Your offset time is: 2024-11-24 19:26:27