Set Object1.ImagePoint to Object2.ImagePoint

Get help using Construct 2

Post » Mon Feb 11, 2013 10:02 pm

I'm attempting to create a pseudo-3D box.

- Two sprites make up the top and bottom of the box - 1 on the "Floor" layer, and 1 on the "Top" layer.
- Pending further adjustments, the paralax for Top is 75, 75, and Floor is 100, 100.
- All sprites have five image points - origin point is at center while the other four are set to each square's corners.
- The Sprite BoxBottom has the Solid behavior.
- The player-controlled sprite, Player, has the 8 Direction, Scroll To, and Bound To Layout behaviors.
- Layout size is 500, 500 with a window size of 250, 250.
- With the exception of TopBox sprite, all sprites are currently on the "Floor" layer.

The viewpoint is while looking top-down (think virtually all the PokeMon games, particularly where the buildings appear 3D as the Trainer moves about town). The lowdown of my goal is to connect the two BoxSide sprites to their respective corners of the BoxTop and BoxBottom sprites. With help of the paralax feature, the BoxTop will move at a different rate than BoxBottom, and the BoxSide sprites will redraw accordingly, creating a simulated 3D effect relative the perspective of the Player sprite as it moves around.

For instance, if Player is standing to the immediate left of the Box, you will barely be able to see the left side. But the further away Player moves to the left, the more the perspective will shift, allowing the left side of the box to be seen. Move to another position around the Box and you'll see a different side of it.

Ultimately, what I'm striving to do is use the image points as anchors at every tick. But I'm not seeing where I can reference one image point of one sprite to that of another sprite's image point. I see the Set Position To events/actions, but not specifically for image points.

My BIG question is if it's even possible to make an image interact between two layers at the same time?

Here's the .capx file at present... https://www.sugarsync.com/pf/D6025908_4317202_6518506

Here is an illustration to (hopefully) make clear(er) what I'm trying to accomplish. The graphics are "pixelated" (easier for me to draw), but it's the color scheme that matters, as that's what I have set up in the .capx above.
https://www.sugarsync.com/pf/D6025908_4317202_6519509Rhindon2013-02-12 20:36:55
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Tue Feb 12, 2013 1:56 am

Yeah you can make images interact between layers (e.g. collisions and such), but with parallax you get some weird effects... I'm not sure exactly what the math is behind it but I think it stretches/shrinks the x,y plane. Spawning something from a sprite in a normal layer into a parallax layer can cause the spawned object to appear quite a distance away from the original's image point.

I'm sure you could account for it with some math. A good start would be to use expressions in the expressions panel where you can use sprite.imagepointX(n) and such to reference image points on a sprite and then try some constant multiplier to counteract the effects of the parallax. You can probably circumvent parallax entirely too, that actually might make some of the math a bit easier.
B
6
S
1
Posts: 40
Reputation: 917

Post » Tue Feb 12, 2013 4:59 am

@Phyvo - LOL Math, in general, I get. Math via C2 is something else at the moment. At least as far as making happen what I want to happen...
How would I access Object 1's image point to be set to Object 2's image point?
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Tue Feb 12, 2013 5:22 am

To put sprite1's image point on top of sprite 2's image point (both non-origin) by setting sprite1's position you'd do this:

sprite 1 set position -
X: sprite2.imagepointX(q)-(sprite1.imagepointX(r)-sprite1.X)
Y: sprite2.imagepointY(q)-(sprite1.imagepointY(r)-sprite1.Y)

I haven't tested that one but I think I got the signs right (it's kinda late for me, zzz). Last time I was faced with this problem I did this which is a little more flashy:

sprite1 set position -
X: sprite2.imagepointX(q) y: sprite2.imagepointY(q)
rotate sprite1 180 degrees
sprite1 set position - X: sprite1.imagepointX(r) y: sprite1.imagepointY(r)
rotate sprite1 180 degreesPhyvo2013-02-12 05:26:54
B
6
S
1
Posts: 40
Reputation: 917

Post » Tue Feb 12, 2013 5:52 am

@Phyvo - I'll give it a go. Thank you!
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Tue Feb 12, 2013 8:52 pm

For clarification, I added a link to an image that better describes what I'm after. Check my second link in the original post.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Tue Feb 12, 2013 9:04 pm

Check out what I did to create a fake 3D box in this thread

http://www.scirra.com/forum/topic62057.html

B
50
S
21
G
8
Posts: 844
Reputation: 10,299

Post » Wed Feb 13, 2013 4:31 am

@justifun - I'm going over your program and it's blowing my mind. VERY awesome. Not what I have in mind, but it's still VERY awesome! I hope to have the insight to do this straight outta my head in due time.
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Wed Feb 13, 2013 4:35 am

@Phyvo - Okay, can you walk me through this? What's this telling C2 to do?
Particularly the parts I have underlined.

X: sprite2.imagepointX(q)-(sprite1.imagepointX(r)-sprite1.X)
Y: sprite2.imagepointY(q)-(sprite1.imagepointY(r)-sprite1.Y)
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Post » Wed Feb 13, 2013 10:34 pm

A refined question to my original post:
Is it possible individually place a sprite according multiple image points on the same sprite? Essentially redrawing/resizing/reshaping the sprite in relation to ANOTHER sprite's image points??

Here is an updated .capx of what I have now...
https://www.sugarsync.com/pf/D6025908_4317202_6510878Rhindon2013-02-13 22:41:27
I'm seeking Narnia. Who wants to come with me! Aslan is on the move!
B
113
S
20
G
8
Posts: 741
Reputation: 13,661

Next

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Artpunk, Magistross and 31 guests