Object moving within a range

Get help using Construct 2

Post » Sat Mar 31, 2012 6:24 pm

Hi~
I have an object (Player) which will only follow the mouse.x axis~
The y axis is a fixed value because I don't wanna to move up & down~
But I want the object move just within a range~

For example, I set a x axis range between 100 and 400~
So that the object will only move within this range~
Even if my mouse axis is over or less than this range~

In detail, let's assume that my mouse is currently at x axis 500~
But the object will still stay on maximum x axis 400~
When my mouse get back to x < 400, the object will follow back~

Same as above, let's assume that my mouse is currently at x axis 30~
But the object will still stay on minimum x axis 100~
When my mouse get back to x > 100, the object will follow back~

How can I do this, I try a whole day still haven't figuring out~
I thought if I make 2 invisible collision objects on left and right~
It will block the player going out from the range but it won't work~
I think is because solid object won't affect mouse controlling object?

So... how can I do this?
Hope somebody know~
Really appreciated~ ^_^AkiraWong2012-03-31 18:26:23
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

Post » Sat Mar 31, 2012 6:50 pm

Made a quick example.

Just one event with two sub-events to check if Y of the object is greater than the constraint and set it to that.
http://www.johnnysix.net/games/this.capx


Here's another example, with interpolated movement ( so there's acceleration on the character)

http://www.johnnysix.net/games/that.capx

See both here:

http://www.johnnysix.net/games/MouseDemoXJohnnySix2012-03-31 19:04:13
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Sat Mar 31, 2012 7:11 pm

Thanks you JohnnySix~
Finally solved this question~
I learned a lot from these~
Thanks~ ^o^
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

Post » Sun Apr 01, 2012 11:54 pm

Looking forward to seeing what you create! :)
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Tue Aug 28, 2012 8:17 pm

Sorry for posting on an old post but JohnnySix, could you please post the .capx for the example on this link? http://www.johnnysix.net/games/MouseDemoX

I want to make a image to scroll like in this game (http://www.pastelportal.com/stories/game.php?id=10gnomes_01) and I think it's possible to achieve it using the movement you applied on the top sprite (the one that looks like a robot).

Thanks in advance!
B
3
Posts: 7
Reputation: 464

Post » Wed Aug 29, 2012 6:58 pm

It's in the march post - "that.capx"

The Mouse Demo just has both capx combined.
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Wed Aug 29, 2012 7:54 pm

@JohnnySix

This.capx and That.capx are the same example (at least for me). Maybe I'm missing something in the event sheet. Would you mind to re-download them and check if I'm correct?

Thanks for your help!
B
3
Posts: 7
Reputation: 464

Post » Fri Aug 31, 2012 8:07 pm

DEMO
http://www.johnnysix.net/games/zzasdfdasf/

CAPX http://www.johnnysix.net/games/zzasdfdasf/blarp.capx

Someone can do it better- this was a quick fudge to show how you might do it. I didn't measure anything.

Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939

Post » Fri Aug 31, 2012 8:08 pm

It runs on preview from Construct, but it looks like the JPG is invisible online.
Image
B
27
S
9
G
5
Posts: 487
Reputation: 11,939


Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, abdalghani, Aurora Australis, imothep85, Marxally, Virpoja and 27 guests