How do I move this sprite with event

0 favourites
  • 8 posts
From the Asset Store
Very simple code without excess options (15 events for server and 11 events for client)
  • Hi , I want to move an sprite about 250px to right by 8-direction behavior when tapped another sprite,How I can Do it? Plz help me

  • Rexrainbow plugin 'moveto' is good for moving a number of pixels in any direction. If you mean just teleport 250px to the right then you can just set a new position for the sprite x+250.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • if u woldv use bullet behavior u wold had the distance traveled.. however since your object is not a bullet and u dont want to mix the 2 of them cause of obvious glitches..

    create a instance variable on the player with the movement controls.

    when any key is pressed (left or right) that enables the movement, triger one time set the instance variable (lets say posx) to players.x then

    compare two variables : distance(player.x,0,player.posx,0) is less then 250 simulate left or right control. that way ur char will only move when the buttons are pressed if the distance is less then 250 pixels. then when u release and press again everything should restart itself.

    Distance limited movement

    if that is what ur not looking for, then what said for the "teleporting movement"setting the .x to + 250 or -250 wold do it.

  • Rexrainbow plugin 'moveto' is good for moving a number of pixels in any direction. If you mean just teleport 250px to the right then you can just set a new position for the sprite x+250.

    Rexrainbow plugin 'moveto' does work with Intel XDK ?

  • Your example was very good but I Want to move 250px just by one tap and not by isTouching , how should I do It?

  • I don't think the C2 plugins matter for Intel XDK, it's not a third party plugin that you add when building with the XDK it's just a thing that is included in the C2 project that you will export before you get to Intel XDK.

  • Thanks Man !

  • Your example was very good but I Want to move 250px just by one tap and not by isTouching , how should I do It?

    that is easy also, however depends what you want to use it with or for, cause if u use some sort of physics, or collision feature behavior with it then u need to create a Boolean and basically change the "on keeping pressed" so it creates a loop, if you dont need physics, same applies, but instead of the 8 way behavior u use "move at angle - pixels "

    edited the capx i added a description for the instance variables also(you can see the meaning of instance variable when u click the Sprite "player" and in left side instance variables, then at bottom of settings u should see a text explaining it.) you can also modify the speed it travels at, however i suggest to do the increase in speed to be something like this (400,800,1000 or any par number increased by power of 2), that wold avoid the player going sometimes to far by 1-5 -10 pixels sometimes.

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