Spawn Actor along finger move
Hello,
I´m new to gamesalad but I've a big problem. Maybe you can help me with that.
I have an animated actor which is 24x20p. I want to spawn it when touch is pressed and spawn along you move your finger.
For example: When i move my finger like a circle it should instantly spawn this actor along this circle.
I watched Tshirtbooths video about how to draw lines, but that isn't exactly that what i´m looking for.
Actor should spawn in the moment you press and move your finger, not after releasing. And without overlapping.
It's very similar to this game:
But my Actors have to move towards the main actor and get faster in 90° direction, because scene isn't moving. This could get a big problem when I'm right.
Thank in advance
I´m new to gamesalad but I've a big problem. Maybe you can help me with that.
I have an animated actor which is 24x20p. I want to spawn it when touch is pressed and spawn along you move your finger.
For example: When i move my finger like a circle it should instantly spawn this actor along this circle.
I watched Tshirtbooths video about how to draw lines, but that isn't exactly that what i´m looking for.
Actor should spawn in the moment you press and move your finger, not after releasing. And without overlapping.
It's very similar to this game:
![](https://img.youtube.com/vi/4kgBL38NiEI/0.jpg)
But my Actors have to move towards the main actor and get faster in 90° direction, because scene isn't moving. This could get a big problem when I'm right.
Thank in advance
Comments
that was one of my fears about the performance, but recycling should't be a big problem, because the actors will more off the scene very quickly.
I tried the drawing template with my actor but the results are strange.
http://s1.directupload.net/file/d/3067/mghlfnc2_png.htm
In relation how fast i move the mouse the size of the actors scale. Either they are stretched when draw them fast or squeezed when i draw slow.
This is element is VERY important for my game because the whole gameplay is based on this so I hope there is a solution for this.
The actors should spawn abreast in their right size and without overlapping when drawing slowly.
Thanks to you both
do you have some ideas to fix this issue? I really have no idea
Thanks
One way to do this would be to have two actors; 1) a sensor that covers the area where actors can spawn, and 2) the actor to be spawned (the cloud thingy). Also, three attributes are needed; 1) distance, 2) previousX, and 3) previousY. The behaviors would look something like this (in the sensor actor):
Rule: When touch is inside
--Timer every .02 seconds
---- Change Attribute: self.distance To:magnitude(game.Mouse.Position.X-self.prevX, game.Mouse.Position.Y-self.prevY)
----Rule: When self.distance > 20
------Spawn Actor: CloudThingy, Position>: game.Mouse.Position.X, Position^: game.Mouse.Position.Y
------Change Attribute: self.PrevX To: game.Mouse.Position.X
------Change Attribute: self.PrevY To: game.Mouse.Position.Y
That should do it!
Note: If you are uncomfortable with spawning actors, you can replace the spawning part with a recycling algorithm.
The Actors spawn at the right size, not stretched or squeezed BUT
it seems like the distance rule isn't working correctly. When I move the mouse slowly the actors are overlapping and when i move it fast theres a big gap between the spawned actors (hope you understand what i mean^^). It shouldn't make any difference how fast you move your mouse/finger.
It seems like the distance condition only check if i want to spawn a new "line". So I can't spawn it right near the other actors.
It should look exactly like in the video i posted in my starting post if this is possible.
Heres a picture of the rules:
http://s14.directupload.net/file/d/3068/8tpk2waz_png.htm
And @Bilal15 maybe this helps you, check it out
Edit: Maybe its important to know that the clouds are moving upwards, so that only hold your finger at the same position should spawn another actor if the condition is true.
It will work better if you put the the distance calculation inside the timer block. (Put it just above the rule.)
Also, you should make the timer go faster by making it .02 seconds (rather than .1 second).
Also, you can change the "20" to whatever width your spawned actors are (plus another 10 to 20 pixels to give some distance between them). So... if the spawned actor is 25 pixels wide, you should change the "20" to something like 35 or 40.
This is working better but still not like expected, I've recorded a video to demonstrate it.
You'll notice that the actor spawning is relative to the speed i move the mouse. When i move to slowly it won't spawn any actor except the first cloud. But when moving to fast theres a big gap between spawned actors. Its a bit random if they spawn or not.
I've played a bit with the numbers but the difference isn't that huge.
Maybe you have an idea what the problem is.
Thank you
Rule: When touch is pressed
-- Change Attribute: self.spawnX To: game.Mouse.Position.X
-- Change Attribute: self.spawnY To: game.Mouse.Position.Y
-- Spawn Actor: Cloud, Position>: self.spawnX, Position^: self.spawnY
-- Constrain Attribute: self.distance To:magnitude(game.Mouse.Position.X-self.spawnX , game.Mouse.Position.Y-self.spawnY )
-- Constrain Attribute: self.angle To: vectorToAngle(game.Mouse.Position.X-self.spawnX , game.Mouse.Position.Y-self.spawnY )
-- Rule: When self.distance > 20
---- Timer For 0 seconds
------ Change Attribute: self.distance To: 1
---- Change Attribute: self.spawnX To: self.spawnX+20*cos(self.angle)
---- Change Attribute: self.SpawnY To: self.spawnY+20*sin(self.angle)
---- Spawn Actor: Cloud, Position>: self.spawnX, Position^: self.spawnY
@Bilal15 Try it, if you haven't
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS
Actually, GameSalad makes it easy to do vectors and angles. What a great product! No trig! No ATAN2! And it's in degrees (Not radians)!