How could i get the mouse press positions set.

Discussion and feedback on Construct 2

Post » Mon Aug 01, 2016 1:28 pm

I try use Array to recording the position of mouse at every times press.
But i don't know how could get a index to write array elements. I use a Text box and i set the type be Number. Hope i can get the number as Array's index. But it's always said "this parameter requires a number, not a string"!! I know it's need a int or something. but there is no integer or another type. Someone help me? for this stupid problem...
B
4
Posts: 1
Reputation: 202

Post » Mon Aug 01, 2016 2:24 pm

I think the easy way is to it let make the index by it self. To do that use Array > action > Push.

If you do that, you have 2 options.
Option 1: Start with an empty array. (dimensions 1,3,1). To let it fill the array with an unlimeted amount of mouse coordinates.

Every tick
Action > Array > Push ... X axis .. value dont matter ... front
Action > Array > Set at XY > X=0 .. Y=1 .. value = Mouse.X
Action > Array > Set at XY > X=0 .. Y=2 .. value = Mouse.Y

Now the array fills, with the latest coordinates at index X=0

Option 2: Suppose you want to store a limited amount of mouse coordinates. Lets say 2000. Then you start with an array with dimensions 2000,3,1.
Now.

Every tick
Action > Array > Push ... X axis .. value really dont matter... front
Action > Array > Set at XY > X=0 .. Y=1 .. value = Mouse.X
Action > Array > Set at XY > X=0 .. Y=2 .. value = Mouse.Y
Action > Array > Pop > X axis ... back.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950


Return to Construct 2 General

Who is online

Users browsing this forum: db3344 and 15 guests