How do I move a sprite going up with constant speed?

Get help using Construct 2

Post » Mon Apr 21, 2014 1:33 pm

How do I move a sprite going up with constant speed?
I tried using the bullet behavior, setting it at negative gravity, but it seems the speed is not constant. Any idea guys on how to solve this?

thanks in advance
B
47
S
14
G
20
Posts: 87
Reputation: 12,913

Post » Mon Apr 21, 2014 2:08 pm

Bullet behavior will make an object travel in one direction at constant speed unless you add acceleration, gravity or other movement to it.

You can just set your object's angle to -90 and some constant speed value you want into "speed" value of bulleet behavior, and that should do the trick.

If you need more assistance, feel free to ask.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Apr 21, 2014 10:24 pm

keroberos wrote:Bullet behavior will make an object travel in one direction at constant speed unless you add acceleration, gravity or other movement to it.

You can just set your object's angle to -90 and some constant speed value you want into "speed" value of bulleet behavior, and that should do the trick.

If you need more assistance, feel free to ask.


Bout the -90 angle where do I put this value, the parameter to set angle on the bullet behavior can only be set to YES or NO.
B
47
S
14
G
20
Posts: 87
Reputation: 12,913

Post » Tue Apr 22, 2014 12:55 am

When you added a behavior, all related parameters of such behavior will be listed on the left panel. Left click on your sprite that has bullet behavior and look on your left panel. Scroll around a bit. You should see those parameters.

I am on mobile right now so I cant snapshot this for better clarification. But I would rather advise you to start with basic beginner tutorial first before anything else. See tutorial section and go step by step with those.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Tue Apr 22, 2014 1:29 am

With so much functions in C2, I guess it would take me a bit more time to learn C2. I've been thru those basic tutorials. What I did was, after adding the bullet behavior, I went to the event sheet and set this parameters:

SYSTEM>EVERY TICK>SPRITE>SET ANGLE TO -90 DEGREES

It did work, it moves upward, it has the constant speed,, but seems its moving sideways (the right side is the one moving upward, like being rotated counter clockwise -90 :mrgreen: ). What I want to happen is the head or top of the object the one moving upward. I guess I'm missing another parameter setting.
B
47
S
14
G
20
Posts: 87
Reputation: 12,913

Post » Tue Apr 22, 2014 1:37 am

if you want your sprite to just move up, you don't even have to use the bullet behavior.

In the event sheet create a new event and add every tick as a condition and for an action (for the object you want to move) choose set Y and write the following expression: self.Y - (any value) * dt

It should look like this:

Every tick---> Object | set Y to self.Y - (any value) * dt

This means that |every frame | your object will look at its current Y position (self.Y) | and it will subtract (move up) some value of pixels (the any value that you will set) |, which by using delta time (dt) you are making sure it will stay the same per second -no-matter the frame rate of the device that the game will be played.
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Tue Apr 22, 2014 1:48 am

Also keroberos is telling about this:

Image
B
31
S
13
G
6
Posts: 355
Reputation: 5,058

Post » Tue Apr 22, 2014 8:05 am

eli0s wrote:if you want your sprite to just move up, you don't even have to use the bullet behavior.

In the event sheet create a new event and add every tick as a condition and for an action (for the object you want to move) choose set Y and write the following expression: self.Y - (any value) * dt

It should look like this:

Every tick---> Object | set Y to self.Y - (any value) * dt

This means that |every frame | your object will look at its current Y position (self.Y) | and it will subtract (move up) some value of pixels (the any value that you will set) |, which by using delta time (dt) you are making sure it will stay the same per second -no-matter the frame rate of the device that the game will be played.


:D Finally got it working.
thank you so much eli0s for your help, there are so much you can do with C2 on how or what approach you want your object to do, for beginners like me, learning stuff like this from C2 masters 8-) like you, would educate me more quiker on C2.

thanks again, also to keroberos & katzin as well
B
47
S
14
G
20
Posts: 87
Reputation: 12,913

Post » Tue Apr 22, 2014 12:40 pm

I am sooooo far from being a master that is embarrassing... But you're welcome!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Fri Apr 25, 2014 7:44 am

eli0s wrote:I am sooooo far from being a master that is embarrassing... But you're welcome!


Hey eli0s,

One last question.

Is it possible or advisable to set the parameter of pixel per second with a half value in bullet behavior or on the set X or Y actions dt, say for example 51pps deviding it by 2 so it will be 25.5

Will this cause any problem with your game when exporting to mobile?
B
47
S
14
G
20
Posts: 87
Reputation: 12,913

Next

Return to How do I....?

Who is online

Users browsing this forum: plinkie, tarek2, zenox98 and 15 guests