deathangel1479's Forum Posts

  • Depends, IMHO behavior is easier to use and more logical, because json objects belongs to the instance and is easily accessible that way.

    What I mean is the ForEach/Count of the plugin works well for behavior object. They are not needed in behavior itself.

    If you have them in behavior, for example you need to pick the correct instance to have a valid foreach (handler,key,value), thats brings all mussy.

    They are like system expressions, you also dont have a foreach in every sprite to go through sprites, you have it in system and input the sprite, true?

  • I tried the behavior, so far it's usefull, but it's missing one important feature - get length of the object and forEach to go through the objects.

    I only builded a dataspace in behavior.

    The tools are in the plugin. You think it make sense to have it in behavior, so in every instance?

  • So, I added a behavior.

    Works like the plugin...

    I add infos later.

    Now for this its easier:

    instance.DirectData.Set("firstpath,secondpath","hello")

    or

    instance.DirectData.Set("firstpath","{""secondpath"":""hello""}")

    ------------------------------------

    Sort I have never needed, will look for it.

  • Why not instance variables with JSON in?

    You can try my prototype: Plugin

    Looks more complicated than it is.

    I manage complicated dictionaries with it.

    You can do:

    Add instance variable to instance, for example myobj set it default "{}"

    instance.myobj = DirectData.SetToObject(object.myobj,"firstpath,secondpath","hello")

    or something like

    instance.myobj = DirectData.SetToObject(object.myobj,"firstpath","{""secondpath"":""hello""}")

    ------------------------------------

    But yes, I will anyway adopt it to a behavior.

  • Thats what I mean, you dont see it... Its only collide.

    You need to set the sprite collision polygon. Collision has nothing to do with transparency.

    In sprite editor bottom left.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • what you mean with "sprite touches other object", visible overlapping or you mean in code?

    I never tried gif, why not png?

  • Sure:

    Order your layouts and use:

    go to next/pervious layout

    or

    global last layout or dictionary all previous layouts.

    On click back - go layout by name

    All in System.

  • Scirra Development, can you add an Mouse/Keyboard click/press(release) reset?

    If you have two Buttons(Sprites) one above the other (two menu windows), you click both.

    You can add a inst var to disable but thats no result, because if first comes the right one, do its stuff and reenable the second like a Ok and return or cancel button, the sheet continues and also click the second.

    Same for Keyboard, if you press(release) a key, wich can do more than one thing. (Open and close menus)

    If there were an action/expressin to reset Mouse/Keyboard current state(for both separately), that would go!

    And I have a additional question:

    I am right that Mouse.OnObjectClicked is a release? Because clicked is past, and there is no extra release for this.

  • It's much easier to work with the json, isn't it?

  • Thats not real a problem.

    I think you only need to think beyond the toturials.

    And maybe browse the custom plugins.

  • First problem solved, I edit it.

    Second problem is a little tricky.

    Thats because the value is set a few ms after the layer is shown.

    Solutions:

    1. You can solve this if you show/create the Objects first if the values are loaded.

    2. You can hide it with for example a fader.

    3. You can solve it with another layer before this one and load the Storage there and then go to the second layer(current).

    But its only a example...

    You also can add another var to set it after unmute to last value, and much other....

  • I work with Smartfox 2X Server. (100 user slots is free)

    It is very doable, but very hard to understand for beginners.

    A few hundret lines java, some mysql tables and it does all you want. That is fast done.

    But you also need to write one or more Construct plugins to handle sends and data.

    And you need a RootServer, thats also a problem. Not to buy, but to hold it safe. Better is Photon, it works with cloud, but I dont know how it works...

    In my project, and I think its normal, the Construct part is much bigger! Where, what, when send or get and work with much big dictionarys.

    In SFS its only income message, set or get some data, send a message back, no big work.

    To be able to assess the work, I give you an example how a SFS Server extension can look like:

    CreateCharacter.java: (looks harder as it is, most is duplicated...)

    package com.zerno.main;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    
    import com.smartfoxserver.v2.db.IDBManager;
    import com.smartfoxserver.v2.entities.User;
    import com.smartfoxserver.v2.entities.data.ISFSObject;
    import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
    import com.smartfoxserver.v2.extensions.ExtensionLogLevel;
    import com.smartfoxserver.v2.extensions.SFSExtension;
    import com.zerno.helper.Globals.ErrorCodes;
    import com.zerno.helper.SendError;
    import com.zerno.helper.Validators;
    
    public class CreateCharacter extends BaseClientRequestHandler {
    
    	@Override
    	public void handleClientRequest(User user, ISFSObject params) {
    		
    		// create objects
    		SFSExtension ext = getParentExtension();
    		IDBManager dbManager = getParentExtension().getParentZone().getDBManager();			
    		Connection cn = null;
    		
    		// create vars
    		int acc_id = user.getVariable("acc_id").getIntValue();
    		String className = this.getClass().getSimpleName();
    		int char_count_max = 0;
    		
    		// create vars from params
    		String name = "";
    		String second_name = "";
    		int gender = 0;
    		int race = 0;
    		int map = 0;
    		int location_x = 0;
    		int location_y = 0;
    		int location_a = 0;
    		String look = "";
    		
    		try{ name = params.getUtfString("name"); }
    		catch(Exception e)
    		{
    			// send name string error
    			new SendError(ext, className, user, ErrorCodes.INVALID_CHAR_NAME_STRING, e.getMessage());
    			return;
    		}
    		try{ second_name = params.getUtfString("second_name"); }
    		catch(Exception e)
    		{
    			// send name string error
    			new SendError(ext, className, user, ErrorCodes.INVALID_CHAR_SECOND_NAME_STRING, e.getMessage());
    			return;
    		}
    		try	{ gender = params.getInt("gender"); }
    		catch(Exception e)
    		{
    			// send gender int error
    			new SendError(ext, className, user, ErrorCodes.INVALID_GENDER_INTEGER, e.getMessage());
    			return;
    		}
    		try { race = params.getInt("race");	}
    		catch(Exception e)
    		{
    			// send race int error
    			new SendError(ext, className, user, ErrorCodes.INVALID_RACE_INTEGER, e.getMessage());
    			return;
    		}
    		try { look = params.getSFSObject("look").toJson(); }
    		catch(Exception e)
    		{
    			// send look string error
    			new SendError(ext, className, user, ErrorCodes.INVALID_LOOK_OBJECT, e.getMessage());
    			return;
    		}
    		
    		// check name string
    		if(!Validators.validate(ErrorCodes.INVALID_CHAR_NAME_STRING, name))
    		{
    			// send name string error
    			new SendError(ext, className, user, ErrorCodes.INVALID_CHAR_NAME_STRING, "");
    			return;
    		}
    		// check second_name string
    		if(!Validators.validate(ErrorCodes.INVALID_CHAR_SECOND_NAME_STRING, second_name))
    		{
    			// send name string error
    			new SendError(ext, className, user, ErrorCodes.INVALID_CHAR_SECOND_NAME_STRING, "");
    			return;
    		}
    		// check gender int
    		if (!Validators.validate(ErrorCodes.INVALID_GENDER_INTEGER, gender))
    		{
    			// send gender int error
    			new SendError(ext, className, user, ErrorCodes.INVALID_GENDER_INTEGER, "");
    			return;
    			
    		}
    		// check race int
    		if(!Validators.validate(ErrorCodes.INVALID_RACE_INTEGER, race))
    		{
    			// send race int error
    			new SendError(ext, className, user, ErrorCodes.INVALID_RACE_INTEGER, "");
    			return;
    		}
    		
    		// create SQL connection
    		try
    		{
    			cn = dbManager.getConnection();
    			PreparedStatement st = null;
    			ResultSet rs = null;
    			
    			// get char_count_max
    			try
    			{
    				// create SQL query
    		        st = cn.prepareStatement("SELECT `char_count_max` FROM `user_accounts` where `acc_id` = ? ");
    			    st.setInt(1, acc_id);
    		        rs = st.executeQuery();
    		        
    			    // verify that a record was found
    	 			if (rs.first())
    	 			{
    	 				// set var
    	 				char_count_max = rs.getInt("char_count_max");
    	 			}
    	 			else
    	 			{
    	 				// send unknown acc_id error
    	 				new SendError(ext, className, user, ErrorCodes.INVALID_ACCOUNTID, "");
    					return;
    	 			}
    			}
    			catch (SQLException e)
    			{
    				// send SQL error
    				new SendError(ext, className, user, ErrorCodes.SQL_ERROR, e.getMessage());
    				return;
    			}
    			finally
    			{
    				// close statement and result
    				try { if( rs != null ) rs.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    				try { if( st != null ) st.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    			}
    			
    			// get character count
    			try
    			{
    				// create SQL query
    		        st = cn.prepareStatement("SELECT COUNT(*) FROM `user_characters` where `acc_id` = ? ");
    			    st.setInt(1, acc_id);
    		        rs = st.executeQuery();
    		        
    			    // verify that record was found
    	 			if (rs.first())
    	 			{
    	 				// check character space
    	 				if(rs.getInt("COUNT(*)") >= char_count_max)
    	 				{
    	 					// send character space error
    	 					new SendError(ext, className, user, ErrorCodes.NOT_ENOUGH_CHARACTER_PLACES, "");
    						return;
    	 				}
    	 			}
    			}
    			catch (SQLException e)
    			{
    				// send SQL error
    				new SendError(ext, className, user, ErrorCodes.SQL_ERROR, e.getMessage());
    				return;
    			}
    			finally
    			{
    				// close statement and result
    				try { if( rs != null ) rs.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    				try { if( st != null ) st.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    			}
    			
    			// get char_count_max
    			try
    			{
    				// create SQL query
    		        st = cn.prepareStatement("SELECT * FROM `race_positions` where `race_id` = ? ");
    			    st.setInt(1, race);
    		        rs = st.executeQuery();
    		        
    			    // verify that a record was found
    	 			if (rs.first())
    	 			{
    	 				// set var
    	 				map = rs.getInt("map");
    	 				location_x = rs.getInt("location_x");
    	 				location_y = rs.getInt("location_y");
    	 				location_a = rs.getInt("location_a");
    	 			}
    	 			else
    	 			{
    	 				// send unknown acc_id error
    	 				new SendError(ext, className, user, ErrorCodes.INVALID_RACE, "");
    					return;
    	 			}
    			}
    			catch (SQLException e)
    			{
    				// send SQL error
    				new SendError(ext, className, user, ErrorCodes.SQL_ERROR, e.getMessage());
    				return;
    			}
    			finally
    			{
    				// close statement and result
    				try { if( rs != null ) rs.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    				try { if( st != null ) st.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    			}
    			
    			// insert character
    			try
    			{
    				// create SQL query
    				st = cn.prepareStatement("INSERT into `user_characters`(`acc_id`, `name`, `second_name`, `gender`, `race`, `current_map`, `location_x`, `location_y`, `location_a`, `look`) values ( ? , ? , ?, ?, ?, ?, ?, ?, ?, ? )");
    				st.setInt(1, acc_id);
    				st.setString(2, name);
    				st.setString(3, second_name);
    				st.setInt(4, gender);
    				st.setInt(5, race);
    				st.setInt(6, map);
    				st.setInt(7, location_x);
    				st.setInt(8, location_y);
    				st.setInt(9, location_a);
    				st.setString(10, look);
    				st.executeUpdate();
    			}
    			catch (SQLException e)
    			{
    				// send SQL error
    				new SendError(ext, className, user, ErrorCodes.SQL_ERROR, e.getMessage());
    				return;
    			}
    			finally
    			{
    				// close statement and result
    				try { if( rs != null ) rs.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    				try { if( st != null ) st.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    			}
    		}
    		catch (SQLException e)
    		{
    			// send SQL error
    			new SendError(ext, className, user, ErrorCodes.SQL_ERROR, e.getMessage());
    			return;
    		}
    		finally
    		{
    			//close connection
    			try { if( cn != null ) cn.close(); } catch( Exception e ) {new SendError(ext, className, user, 0, e.getMessage());}
    		}
    		
    		// send success
    		send(className + "Success", null, user);
    		trace(ExtensionLogLevel.INFO, className + ": " + acc_id);
    	}
    	
    }
    [/code:3acd9izm]
    
    My extension file list:
    [img="https://dl.dropboxusercontent.com/u/95601836/javalist.png"]
  • The get value need to int... Seem Storage give always a string.

    I also added the correct math for percent.

    volume2

  • Thats easy, because every tick is faster than the hole local storage get.

    You set the local Storage, before you got it.

    Set it later, for example: on slider value change.

  • Regex.

    This one is for A-Z a-z 0-9 and length of 5-20.