How do I select an instance of an object and rotate it

Just started using Construct 2? Post your questions here

Post » Mon Jul 28, 2014 11:50 pm

basically what i want to do is to select an instance of and object when i touch it then when selected i want a small curved line to show up and when i drag the line the image instance rotates according to the line.

in other words i want to rotate the object the same way i can before i run the layout.

please i need this and fast!!
Banned User
B
7
S
1
Posts: 57
Reputation: 555

Post » Tue Jul 29, 2014 11:36 am

I'm not sure to fully understand what you mean.

If you check out the how do I FAQ, you can probably mix some items like
"Several RTS mechanics (camera movement, selecting units, etc...) - LINK"

and

"Resize handles on a sprite example - LINK"

To make some kind of interface like your are looking for maybe ?

As to rotate, it's based on the "Set angle" action of your objects/instances.

Perhaps post a capx with a detailed explanation of your interface as you have it at the moment.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Wed Jul 30, 2014 8:48 am

I think I understand what you mean. This "may" help or be relevant to what you want:

Add the Touch element to your Layout then in the Event sheet:

On Touched Sprite (Object you touched) > (Object you touched) Spawn Another Object (Line you want to use).
On Touched Sprite (Line) > Set angle towards position (Line.X, Line.Y).

This should set the angle of the sprite spawned towards the position of the line as you drag it.

If you'd like to touch once and then the sprite gets attached to the touch of your finger and move around, I believe you'll need an Every Tick event and a variable.

There is a .capx file attached for you to take a look at but uses mouse instead of Touch. I believe you'd be able to tailor it to your need.

Hope that helps.
You do not have the required permissions to view the files attached to this post.
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Wed Jul 30, 2014 8:56 pm

what i actually ment by a line is simply a curved line on the corner of my object that once i selected it and started dragging the exact instance of the object( since i have many instances) would rotate with the line towards the mouse.

i mean exactly how you would re position and rotate any object in construct 2 before you run it.
Banned User
B
7
S
1
Posts: 57
Reputation: 555

Post » Wed Jul 30, 2014 8:58 pm

i made allot of progress and got what i want if there was no instances of my object since now all of them rotate with the line and that is because i still didn't figure out how to pick both the line and the "instance" of the object at the same time.
Banned User
B
7
S
1
Posts: 57
Reputation: 555

Post » Wed Jul 30, 2014 9:00 pm

i made allot of progress and got what i want if there was no instances of my object since now all of them rotate with the line and that is because i still didn't figure out how to pick both the line and the "instance" of the object at the same time.
Banned User
B
7
S
1
Posts: 57
Reputation: 555

Post » Wed Jul 30, 2014 9:11 pm

Why not try a System > Pick instance based on UID? Or perhaps an expression?
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Wed Jul 30, 2014 9:24 pm

i already did that. what i did is making a global variable that gets the uid of the object i click. so when i click something i pick it with this variable though my problem is picking 2 objects at once the line and the object instance
Banned User
B
7
S
1
Posts: 57
Reputation: 555

Post » Wed Jul 30, 2014 9:41 pm

Why not have 2 variables (if you want to identify two objects). One variable is set with a condition that the Mouse On Object Click (sprite you want clicked) and the other would store the UID for the Mouse on Object Click (the line)?

That way the first variable is only set with objects that are sprites and the second can only be changed by the line types. Would that work?
B
19
S
7
Posts: 161
Reputation: 1,751

Post » Thu Jul 31, 2014 11:35 am

It would be simpler if you posted/attached your capx.
From the get go we are supposed to follow your "progresses" based on your vague explanations.

Anyway here's an example of implementation that should fit with what you need.
You do not have the required permissions to view the files attached to this post.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests