How do I exactly stop the bullet at position ?

0 favourites
  • 14 posts
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • hi all,

    i just want to stop bullet of a sprite at exact position (x or y)

    i use if sprite.X < 80 set bullet desable or sprite.x > 80 set x to sprite.-5*60*dt

    but always it stop at different X

    see .capx https://www.dropbox.com/s/o4dn71frsdheu ... .capx?dl=0

    thanks for help

  • You might want to take a look at rexrainbow's MoveTo plugin. You can use it to move a bullet an exact distance, at an angle and speed, or to a point in space. His PushOutSolid plugin can be used if you want the bullet to stop precisely at a solid wall

  • 7Soul

    that's ok it work for moving object

    but if for example i want to set an image with this (if with of sprite < 400 then set sprite.width to self.widht-10*60*dt)

    it always stop at different with and not exactly to 400

    any suggest ?

  • Use max() and it will stop exactly at 400.

    +-------------------+
    | sprite: width<400 | sprite: set width to max(400, self.width-10*60*dt)
    +-------------------+[/code:2ox87p20]
    
    If the value is increasing instead you can use min().
  • thanks a lot really appreciate it

    and then i can also use it for if x < 400 (for example) without use the moveto rex plugin ?

  • For that simple case, yes.

  • Use max() and it will stop exactly at 400.

    +-------------------+
    | sprite: width<400 | sprite: set width to max(400, self.width-10*60*dt)
    +-------------------+[/code:1nno7ry5]
    
    If the value is increasing instead you can use min().
    

    its stranger .... it set directly width to 400 (without the gradiant effect)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • looking at it again you'll probably want width>400 since by subtracting from the width it should be shrinking.

  • i just would like that for example the object sprite looks small and grow to 400 for 3 or 4 seconds

  • looking at it again you'll probably want width>400 since by subtracting from the width it should be shrinking.

    here is what i want exactly

    but as i told you always stop at different value

    https://www.dropbox.com/s/vrc769cjw12pm ... .capx?dl=0

  • > looking at it again you'll probably want width>400 since by subtracting from the width it should be shrinking.

    >

    here is what i want exactly

    but as i told you always stop at different value

    https://www.dropbox.com/s/vrc769cjw12pm ... .capx?dl=0

    One way of solving it:

    https://dl.dropboxusercontent.com/u/485 ... egrow.capx

  • Or simpler based on LittleStain answer :

    This is a question of comparison sign.

    As long as the object is less (and ONLY less) than the desired size, you make it bigger.

    Once it is bigger (and ONLY bigger) than the desired size, you set it at the desired size.

    Without the "or equal" in your comparison, you're making sure the logic works as intended.

    You are also making sure that as long as the size is less than the desired size, the object will get bigger. The moment the size is reached, it won't grow anymore.

    And you are also making sure that it will be bigger than the desired size only once, since the moment it happens, you set it to the desired size which no event/condition actually acts on anymore.

    Replace 80 with any value, and it will work, as long as it is consistent in both events.

  • Or simpler based on LittleStain answer :

    This is a question of comparison sign.

    As long as the object is less (and ONLY less) than the desired size, you make it bigger.

    Once it is bigger (and ONLY bigger) than the desired size, you set it at the desired size.

    Without the "or equal" in your comparison, you're making sure the logic works as intended.

    You are also making sure that as long as the size is less than the desired size, the object will get bigger. The moment the size is reached, it won't grow anymore.

    And you are also making sure that it will be bigger than the desired size only once, since the moment it happens, you set it to the desired size which no event/condition actually acts on anymore.

    Replace 80 with any value, and it will work, as long as it is consistent in both events.

    Yeah, that's better..

    Sometimes I just want it to work and don't bother finding the easiest way, haha..

  • yes thats awesome

    thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)