dop2000's Forum Posts

  • The way we did this in Moonstone Island was by placing a semi-transparent copy of the character sprite on a layer above. Or you can paste it on a drawing canvas. It won't be dark though:

    The trees are not transparent.

  • Now how do I mark a post as the solution?

    You can edit the subject if you wish, but it's not really necessary.

    After all, how many devs would publish a game under their name? The vast majority would register a business name.

    Lots of people are making games as a hobby and if they publish their games, it's on platforms like Construct Arcade or itch.io. You don't need to register a company for that.

    I agree that the license is expensive. But what do you suggest? Making a "small hobbyist" license which is slightly less restrictive than the trial version and costs only $5 a month?

  • Check out the official example:

    editor.construct.net

    But it's not very good because it doesn't detect touch speed, only the direction between start and end point. Meaning you can randomly move the finger around the screen for a long time and it will still detect it as a swipe.

    A better way to do this is to use Touch.SpeedAt(0) and Touch.AngleAt(0) expressions

    dropbox.com/scl/fi/x34gam8ff3qxk7m8b5ril/SwipeControls.c3p

  • Yes, self.a instead of just "a", but you need to copy/paste this entire expression:

    (anglediff(self.a, 0)<45 ? "Right": anglediff(self.a, 90)<45 ? "Down": anglediff(self.a, 180)<45 ? "Left": "Up")
    

    It's using ternary operators and is a short and efficient way to do this:

    If angle is near 0 degrees - use "Right" animation
    else If angle is near 90 degrees - use "Down" animation
    else If angle is near 180 degrees - use "Left" animation
    else use "Up" animation
    
    
  • I made a small mistake, it should be self.a in the last line.

    And of course put the correct animation names instead of "Left", "Right" etc.

  • There are many ways to do this. For example:

    Every 1 second
    Enemy overlapping PlayerConeOfView
    Enemy Pathfinding NOT moving
    For each Enemy
    
    .. Local variable a
    .. Local variable x
    .. Local variable y
    .. Local variable dist=500
    
    .. set a to angle(player.x, player.y, enemy.x, enemy.y)
    .. set x to enemy.x + dist*random(0.5, 1.5)*cos(a)
    .. set y to enemy.y + dist*random(0.5, 1.5)*sin(a)
    
    .. Enemy Find Path to (x, y)
    
    
    
    Enemy On Path Found: Enemy move along path
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Solution 1 isn't great because on big maps the Pathfinding behavior will be quite slow.

    If your game is grid-based, you can try EasyStarJS behavior, it's much faster. But still will probably struggle if your map is 100000x100000 tiles in size.

    One workaround is to use an invisible tilemap, which you center on the player position and mark all obstacles on it. Then use EasyStarJS to find the path.

  • Are you using Turret behavior just to determine the angle? I'm guessing it won't be good for performance. You can use this expression:

    angle(self.x, self.y, player.x, player.y)

    This will probably be the most efficient way:

    On every tick: 
    
     Enemy set variable a to angle(self.x, self.y, player.x, player.y)
    
     Enemy set animation to (anglediff(a, 0)<45 ? "Right": anglediff(a, 90)<45 ? "Down": anglediff(a, 180)<45 ? "Left": "Up")
    

    "a" is an instance variable on the enemy sprite.

  • What kind of game it is? Top down view? Are there walls, obstacles?

    You can pick a random point and try to find a path to it.

    These are the coordinates of a random spot ~500px away in the opposite direction:

    set a to angle(enemy.x, enemy.y, player.x, player.y)
    set x to player.x + random(400,600)*cos(a)
    set y to player.y + random(400,600)*sin(a)
    
  • You can save object velocity in a variable using this expression:

    set v to distance(0, 0, Obj.Physics.VelocityX, Obj.Physics.VelocityY)

    And restore it after teleporting with "Set velocity" action:

    Set velocity X to v*cos(teleportAngle)

    Set velocity Y to v*sin(teleportAngle)

  • You can set up all spritefonts on an unused layout, add them to a family. Then in runtime create a spritefont by name, or substitute the default spritefont.

    Here is an example from my "Multi Language Support" template:

  • In the last event on your screenshot you are checking the distance to base2. But you need to pick the correct base2 instance first! If you don't pick it, then the distance will always be checked to the first base2 instance only. And other base2 sprites will be ignored.

    In the first event when you are picking the nearest base2 instance, save it in an instance variable on Base sprite as a target. Then you will be able to properly pick target base2 to check if it's in range to start the battle.