Proper use of GetClickPositionX

This forum is meant for posting anything related to Adventure Maker that doesn't fit in the other forums.Please post technical questions in the Technical Support Forum!

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

Proper use of GetClickPositionX

Postby Netjera » Wed Feb 17, 2010 10:52 am

Hi guys,

I'm trying to get some coordinates from mouse click and store them in a variable, as follows:

Code: Select all
xdp = Action.GetClickPositionX


However, nothing is happening in the program when I plug xdp in anywhere, and when I use a msgbox to determine what's happening, it's coming back with an empty value. Am I using this incorrectly?

Thanks!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Mystery » Wed Feb 17, 2010 1:02 pm

Create a large hotspot that covers the screen.
Add to the Advanced Tab of the Hotspot Properties
Code: Select all
xdp=Action.GetClickPositionX
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Netjera » Wed Feb 17, 2010 6:15 pm

That's what I did. (Before I posted the first time.) It's not working. Here's my settings, in case I did something wrong. (Anything not listed, is not activated.)

Project Properties: Plugins: Mobility Xtreme 2.1 (Checked)
Frame Properties: None
Hotspots: (2)

Hotspot #1:
Position: 7, 390
Size: 628, 84
General: Hotspot Appearance: Transparent
Advanced:When the hotspot is clicked, execute some code:
Code: Select all
xdp = Action.GetClickPositionX

Plugins: Move a hotspot when the hotspot is clicked:
The hotspot index: 2
Initial X position: (blank)
Initial Y position: (blank)
Step increase in Pixels for X: (I've tried 5, and 640 here, neither works)
Step increase in Pixels for Y: 0
The Right Limit of X: 640
The Left Limit of X: 0
The Down Limit of Y: 480
The Up Limit of Y: 0
The X Destination: xdp
The Y Destination: 100
Time modifier in ms: 10
Execute some vbs after movement: (blank)

Hotspot #2:
Position: 25, 286
Size: 75 x 140
General: Hotspot Appearance:Picture: Robot_03_01.gif (from the samples)

Sorry about the confusion. I guess I shouldn't post right before I go to bed. I could've SWORN I mentioned I'd put it in the VBScript tab. >.<
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Mystery » Wed Feb 17, 2010 6:25 pm

I haven't tried it in a fancy way with plugins and such, just did a quick test to retrieve the x position:

I added a text by right clicking on the frame, and entered some text (in this case textxpos, but it doesn't matter what you add there).
I created a big hotspot that covers the frame.
I added an integer variable called xpos.
In the Advanced Tab of the Hotspot Properties, I added the following:
Code: Select all
xpos=Action.GetClickPositionX
Text(1) = xpos


When I tested, I just clicked somewhere on the screen, and the text on the frame displayed a value that looked correct to me.

Question:
Did you create an integer variable xdp?
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Netjera » Wed Feb 17, 2010 6:28 pm

Mystery wrote:<snip>

Question:
Did you create an integer variable xdp?


Yes. I put it into VBS Global Variables.

I'm going to try doing what you did and seeing if that works, might give me an idea of what's going on.
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Netjera » Wed Feb 17, 2010 6:36 pm

AHA! Now, this is interesting.

1) I created a new solid colored frame in the same project with EXACTLY your settings. I tested the frame and wherever I clicked, I got a coordinate in the text. Just as you described.

2) I switched to my game frame. Wanting to see what was going on, I added text, and set it to xdp. When I click, I get a numerical position in text.

So for some reason, I'm generating the click position correctly, but the player sprite is not moving to it.
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Mystery » Wed Feb 17, 2010 6:36 pm

Hmmm, another question, how did you assign "Initial X position: (blank)" of hotspot 2 to the variable xdp of hotspot 1?
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Netjera » Wed Feb 17, 2010 6:38 pm

I didn't. There's a small note next to that box that says, "(leave blank for current)". I wanted the player to start wherever I set the sprite, so I left the original position blank.
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Netjera » Wed Feb 17, 2010 6:39 pm

Oh wait, you're talking about crossing the hotspots. I don't do that at all. The plugin does it automatically. You just tell it what hotspot to move when the mouse is clicked, and it uses the settings in the hotspot you click ON (not necessarily the one you're moving)
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Mystery » Wed Feb 17, 2010 6:39 pm

But then this logical step is missing I think.
How should AM or the plugin "know" that the Initial X Position is the value of xdp?

EDIT:
Hmmm, I haven't used this plugin at all, so I can't say much.
I'd have to look into it how it works.
On the other hand if you don't have to make a link between plugin settings and your variable, why are you even using the Action.GetClickPositionX and the variable?
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Netjera » Wed Feb 17, 2010 7:19 pm

The code for moving Hotspot 2 is located in Hotspot 1, in case that wasn't clear. You place all the movement settings in the plugin tab of the hotspot BEING CLICKED.

Typical procedure works like this:

1) Select the hotspot you want to click on. For me, that's a small strip near the bottom of the screen that I want the player to move back and forth within.

2) Determine the hotspot you want to move. I don't want to move the strip, I want to move the player. When the strip is clicked, I want the player to move to the click position.

3) In the plugin properties of the hotspot BEING CLICKED, set up your parameters. You specify FIRST, what hotspot is being MOVED. Then all the settings indicated have to do with THAT HOTSPOT.

4) Since I told the plugin, "When Hotspot 1 is clicked, move hotspot 2" in the first parameter, it automatically looks at the current location of Hotspot 2 - which happens to be where I created it, since I haven't moved it - if I leave the Initial X Position blank. I set up Hotspot 2 at 25, 286, so that's the position it uses.

That's the breakdown on how the plugin works. You can move any hotspot from any other hotspot, which makes the plugin very versatile. Since you can run code after the moving the hotspot, you can do things like, Click Hotspot A to move Hotspot B, which runs code to click Hotspot C which causes Hotspot D to move, and so on. Cascading effects are really easy to set up. So far, I haven't had any issue with the plugin in other games.

I'm using Action.GetClickPosition, because I want the player to move back and forth within the strip, stopping at the click position. If you want an example, juhu posted a sample on page one of the thread, but he never told me how he managed it, and I couldn't access the code, so I've been working on it, on my own. However, his example is exactly how I want the movement to work.
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Netjera » Thu Feb 18, 2010 6:18 am

I GOT IT!

The error was happening because I wasn't converting to Twips!
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Mystery » Thu Feb 18, 2010 6:03 pm

Great, I'm glad that you've been able to figure it out :D
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Netjera » Thu Feb 18, 2010 6:54 pm

Thanks! For some reason, I couldn't get it to work with Mobility Xtreme, even converting into twips. It keeps giving me an "Overflow: xdestination" error.

I had to use:
Code: Select all
getClick = Action.GetClickPositionX
xdp = getClick*15
Hotspot(2).move xdp


He looks a little like he's jumping from location to location, instead of moving smoothly back and forth across the bottom. I'm not sure why mobility isn't working. I tried to use xdp as the reference in X Destination, which *should* work, but for some reason, it's moving in the smallest increments and never to the click location.
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States

Postby Mystery » Thu Feb 18, 2010 7:04 pm

I hope that Doggy will be able to help you out with it as I have absolutely no experience with that plugin.
Btw, thanks for explaining to me how it worked in your earlier post :)
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Netjera » Thu Feb 18, 2010 10:15 pm

No problem. After using it, I think it's really great! Now, if I could just figure out Keyguard. XD I'm finding it... a bit intimidating with how to set it up, and since I don't immediately need its functions, I keep avoiding actually learning it, lol.

Netjera<--- chicken lol
A woman on a mission - a budding artist looking for a place to take root, a builder looking for the right community - I'm looking for a home.
User avatar
Netjera
Frequent Poster
 
Posts: 127
Joined: Sun Jan 24, 2010 8:48 am
Location: United States


Return to Adventure Maker General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests

cron