WackyToaster's Recent Forum Activity

  • This might not be in the latest stable release yet but it's already in the beta.

    editor.construct.net/r387

    The next stable release will (I suspect) drop next week.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Is there any way to "lock" this effect ??

    Not that I'm aware of.

    As I said I'd just make sure it looks good in the preview and ignore how it looks in the editor (or disable it in the editor entirely)

  • Some effects depend on the screen size, and the layout view simply has a different size than the actual view in game. You kind of have to ignore how it looks in the editor since what matters is how it looks in the game. Ideally it would look exactly the same but I'm not sure that's possible for some effects.

  • That's also an option, it was the first thing I thought about actually until I realized you can just do it without an invisible pixel.

  • You can check the console (press f12) for a better error message. Imo this message should actually show in the error popup from construct because the error message otherwise is largely meaningless.

  • My solution would probably be to simply not cast the ray from inside the solid at all. Check this

    But there's also the possibility to use solid collision tags

  • Well this is gonna need some more tinkering. I've managed to update the script more to my workflow, so now it exports each tag as an individual zip. It's a bit rough but it works ok for now.

    The main issue I'm still facing is that cels are not the full image but it's basically the cropped sprite, which for animations causes the origin to go all over the place due to different individual frame sizes. I need to somehow figure out how to get the origin on a consistent spot despite that.

    I can easily get the cel.bounds and I also have the sprite width/height.

    aseprite.org/api/image

    I think that should be everything I need to math it out but my brain is not braining today. Anyway, here's the updated script for now.

    -- Get the active sprite
    local sprite = app.sprite
    
    if sprite == nil then
    	print("No active sprite found.")
    	return
    end
    
    local spriteName = string.match(sprite.filename, "[^/\\]+$")
    spriteName = spriteName:gsub("%..*$", "")
    
    
    -- Create a new dialog
    local dlg = Dialog("Export animation for C3 - this will briefly hang :)")
    dlg:button{ id="confirm", text="Confirm" }
    dlg:button{ id="cancel", text="Cancel" }
    dlg:show()
    
    local data = dlg.data
    
    if data.confirm then
    	-- Extract the directory path of the original sprite file
    	local originalFilePath = sprite.filename
    	
    	local outputFolder = app.fs.joinPath(string.match(originalFilePath, "^(.-)([^\\/]-%.?([^%.\\/]*))$"), "tmp-export-for-c3")
    	if outputFolder == nil then
    		print("Failed to determine output folder.")
    		return
    	end
    	
    	for i, tag in ipairs(sprite.tags) do
    		
    		-- Use the name that was set in the dialog or the file name if no name was specified in the dialog
    		local defaultAnimationName = tag.name
    		
    		-- Construct the JSON data
    		local jsonData = {
    			["use-raw-folder-names"] = true,
    			["animation"] = {
    				["name"] = tag.name,
    				["speed"] = 0,
    				["loop"] = false,
    				["ping-pong"] = false,
    				["repeat-count"] = tag.repeats or 1,
    				["repeat-to"] = 0,
    				["frame-durations"] = {},
    				["frame-tags"] = {},
    				["frame-image-points"] = {}
    			}
    		}
    		
    		if tag.aniDir <= 1 then
    			jsonData["animation"]["loop"] = true
    		else
    			jsonData["animation"]["ping-pong"] = true
    		end
    		
    		local fps = math.floor((1000 / (tag.fromFrame.duration * 1000)) + 0.5)
    		jsonData["animation"]["speed"] = fps
    		
    		-- Flatten to merge all layers
    		local dupe = Sprite(sprite)
    		dupe:flatten()
    		
    		local origin = {{
    			originX = 0.5,
    			originY = 0.5
    		}}
    		
    		for i, cel in ipairs(dupe.cels) do
    		
    			if cel.frameNumber >= tag.fromFrame.frameNumber and cel.frameNumber <= tag.toFrame.frameNumber then
    				local filename = app.fs.joinPath(outputFolder, i .. ".png")
    				
    				cel.image:saveAs(filename)
    				
    				--jsonData["frame-image-points"].inser = {"originX":3, "originY":3}
    				table.insert(jsonData["animation"]["frame-image-points"], origin)
    				
    				local lfps = math.floor((1000 / (cel.frame.duration * 1000)) + 0.5)
    				table.insert(jsonData["animation"]["frame-durations"], math.floor((fps / lfps) + 0.5))
    				end
    		end
    		
    		dupe:close()
    		
    		--app.command.Undo()
    		
    		-- Write JSON data to file
    		local jsonFilename = app.fs.joinPath(outputFolder, "c3-import-settings.json")
    		local jsonFile = io.open(jsonFilename, "w")
    		if jsonFile then
    			jsonFile:write(json.encode(jsonData))
    			jsonFile:close()
    		else
    			print("Failed to generate JSON file.")
    			return
    		end
    		
    		local pathSeparator = package.config:sub(1, 1)
    		-- Choose the appropriate zip command based on the operating system
    		local osType = (pathSeparator == "\\") and "Windows" or "Unix-based"
    		
    		local zipCmd
    		
    		local zipFilename = app.fs.joinPath(outputFolder, defaultAnimationName .. ".zip")
    		
    		if osType:find("Windows") then
    		-- Use PowerShell on Windows
    		zipCmd = 'powershell Compress-Archive -Path "' .. outputFolder .. pathSeparator .. "*" .. '" -DestinationPath "' .. zipFilename .. '" -Force'
    		else
    		-- Use the zip command on Unix-based systems
    		zipCmd = 'zip -r "' .. zipFilename .. '" "' .. outputFolder .. pathSeparator .. "*" ..'"'
    		end
    		
    		-- Execute the zip command
    		os.execute(zipCmd)
    		
    		-- Move the zip file to the new destination path
    		local directoryPath, fileName = zipFilename:match("(.+)[/\\]([^/\\]+)$")
    		local newZipFilePath = app.fs.joinPath(directoryPath, "..", fileName)
    		
    		local moveCommand
    		
    		if osType:find("Windows") then
    		-- Windows system
    		moveCommand = "move".. " " .. zipFilename .. " " .. newZipFilePath
    		else
    		-- Unix-like system (Linux, macOS, etc.)
    		moveCommand = "mv".. " " .. zipFilename .. " " .. newZipFilePath
    		end
    		
    		os.execute(moveCommand)
    		
    		-- Remove the temporary folder
    		local removeCommand
    		
    		if osType:find("Windows") then
    		-- Windows system
    		removeCommand = "rmdir /s /q" .. " " .. outputFolder
    		else
    		-- Unix-like system (Linux, macOS, etc.)
    		removeCommand = "rm -rf" .. " " .. outputFolder
    		end
    		
    		os.execute(removeCommand)
    		
    	end
    end

    Very frustrating. At leas they should allow me to see what I wrote before when I had the license! Seems not fair that what I paid for at the time is not accessible any more.

    You can open any project in the free version even if it's way above the free limits. You just cannot edit it. So you can read through your code as long as you need without having to pay a single cent. If you want to edit, that's where you'll need to buy again.

  • I figured a first attempt would miss the mark, specially because I am sure there are a few popular workflows that people like to use when making their animations. Just wanted to make something because it's easier to tweak an existing script than coming up with it from scratch.

    All good, it's a start and I can try and adapt it when I have spare time. There's no way to make a one-size-fits-all solution anyway. But having a base script to start off of is already really helpful.

    Fortunately I saw in the documentation of Aseprite, that you can assign custom data to frames. That custom information could be used by the exporter to generate C3 tags for each frame.

    That's good news. Probably also useful for adding origin/imagepoint data and such! My ideal would be that I'm able to input practically all the data of a sprite in aseprite, generate a zip (or multiple) and drag & drop it into Construct which then updates all animations with the new settings/data.

    This means some initial extra work but once it's all set up I should be able to iterate on the animations really quickly, and it's all packaged very neatly.

  • I see. I have used both mixins and composition before. I found mixins to be kinda weird and awkward though, so composition is fine. Thanks :)

  • I should post this here too while I'm at it.

    Subscribe to Construct videos now
  • Hmmm

    In any case if you're legit I recommend running away from this project as fast as possible because Nintendo is going to DMCA you quicker than you can catch your first pokemon.

WackyToaster's avatar

WackyToaster

Member since 18 Feb, 2014

Twitter
WackyToaster has 26 followers

Connect with WackyToaster

Blogs