A little Help

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I have a few questions that i could not find an answer for.

    How do i use private variables in objects in python?

    When i have something like such

    Monster.Hp -= 1

    I get a nonetype to int error

    Also how do i spawn things using python ive tried a few things but nothing came out.

  • Private variables in python are accessed much like with events.

    # This gets the value
    Sprite.Value('HP')
    # This sets the value to 22
    Sprite.SetValue('HP', 22)
    #This subtracts 1 from the value
    Sprite.SubValue('HP', 1)[/code:3nd2pf6i]
    
    Same deal with creating objects:
    [code:3nd2pf6i]# This creates a Sprite on layer 1 at 200,300
    System.Create('Sprite', 1, 200,300)[/code:3nd2pf6i]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, I actually figured those things out after while of playing around, i just looked in the menu that appears when u add the dot to an object.

    My current dilemma in my ongoing project of trying things out is finding an effective way to make the player unable to move through specific objects (walls).

    Maybe you can help me figure this out too.

    I have set collision masks on both the wall and object.

    Im not using any behavior because i wanted to constrain the player to the layout.

    I just made a group of events like such

    +Movement
      -When Key Up Is Down && Player.Y < 975
          -Save Old Y to Private var
          -Player.Y += 2
      -When Key Up Is Up && Player.Y > 25
          -Save Old Y to Private var
          -Player.Y -= 2
      -When Key Up Is Right && Player.X < 975
          -Save Old Y to Private var
          -Player.Y += 2
      -When Key Up Is Left && Player.X > 25
          -Save Old Y to Private var
          -Player.X -= 2
       When Player is Overlapping Wall
         Player.X = OldX
         Player.Y = OldX
    [/code:17juojze]
    
    But doing that the wall is very rough like i cant go up and down the wall, and occasionally i go into the wall :/. My wall is a 50X 50Y block as a test. :/ Any ideas?
  • To prevent going into the wall you could add a "overlapping at offset" condition to check for collisions before motion.

    + MouseKeyboard: Key Left arrow is down
    + Sprite: [negated] Sprite: overlaps "Solid" : offset (-1,0)
    -> Sprite: Set X to.X-1
    
    + MouseKeyboard: Key Right arrow is down
    + Sprite: [negated] Sprite: overlaps "Solid" : offset (1,0)
    -> Sprite: Set X to.X+1
    
    + MouseKeyboard: Key Up arrow is down
    + Sprite: [negated] Sprite: overlaps "Solid" : offset (0,-1)
    -> Sprite: Set Y to.Y-1
    
    + MouseKeyboard: Key Down arrow is down
    + Sprite: [negated] Sprite: overlaps "Solid" : offset (0,1)
    -> Sprite: Set Y to.Y+1
    [/code:31phvxjq]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)